eval-in-repl
eval-in-repl copied to clipboard
Blank lines in python functions don't work
Given the function:
def foo():
x = 1
y = x + 1
eir-eval-in-python
makes python/ipython thinks that the function ends after x = 1
, and tries to evaluate y = x + 1
, producing NameError
.
Looks like eir-send-to-python
is getting the whole string, but it's being misunderstood by the inferior python process. It is possible to send whole functions to *Python*
buffers, python-shell-send-defun
does the right thing, so I'm not sure what needs changing.
Thanks for your interest in the package. I wasn't aware of this. Deleting the blank line before reaching the inferior python process may be a quick fix. I'm currently busy, so I'll work on this later this month.
Yeah, unfortunately this seems like a deal-breaker for Python. For example, I just selected all but one line of a Python script and hit C-RET, and I got a buffer full of tracebacks, mostly about indentation errors. But if I call python-shell-send-region
on the same region, it works fine.
Can you give me a reproducible example script?
def test_function(t):
print t
print t
print "ok"
test_function("ok")
C-x h C-RET
:
>>> ... ... >>> File "<stdin>", line 1
print t
^
IndentationError: unexpected indent
>>> >>> ok
>>> >>> ok
Hi, I'm facing this issue as well. Any workaround for this, other than the remove blank lines?
I just released 0.9.5 to address this issue. Please let me know if it works better for you. If this new behavior seems satisfactory, I'll close the issue.
Add eir-use-python-shell-send-string
option (default to t
). This avoids errors on blank lines by using python-mode
's python-shell-send-string
function. However, this does not allow showing code in the REPL. To recover the old behavior, set to nil
.
0.9.5 https://github.com/kaz-yos/eval-in-repl/releases/tag/v0.9.5