emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] ob-python newline & indentation behavior


From: Jack Kamm
Subject: [O] ob-python newline & indentation behavior
Date: Sat, 18 Nov 2017 12:02:24 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

ob-python newline & indentation behavior in :session is very ugly and possibly broken. For example, consider the following code block:

#+BEGIN_SRC python :session :results output
  foo = 0
  for _ in range(10):
      foo += 1

      foo += 1

  print(foo)
#+END_SRC

Ideally this would print "20", but instead it prints "11",
because the second "foo+=1" is executed after the for loop.
OTOH "python-shell-send-region" (from python.el) gives the correct answer of "20".

The inconsistent behavior of "python-shell-send-region" and "org-babel-eval" often causes me problems, because I want to use both (the former for testing and async eval; the latter for inserting into the document).

There is a 2 year old patch that fixes this behavior but has not yet been incorporated:
https://lists.gnu.org/archive/html/emacs-orgmode/2015-03/msg00505.html

The patch follows the python.el behavior of using a temporary file and executing that from the shell.

Could this patch, or something similar, be incorporated into org-mode, to fix this behavior?

Thanks,
Jack Kamm




reply via email to

[Prev in Thread] Current Thread [Next in Thread]