emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ob-python newline & indentation behavior
@ 2017-11-18 12:02 Jack Kamm
  2017-11-18 15:05 ` Kyle Meyer
  0 siblings, 1 reply; 19+ messages in thread
From: Jack Kamm @ 2017-11-18 12:02 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-12-19  5:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-18 12:02 ob-python newline & indentation behavior Jack Kamm
2017-11-18 15:05 ` Kyle Meyer
2017-11-18 22:15   ` Jack Kamm
2017-11-19  3:27     ` Martin Alsinet
2017-11-19  3:34       ` Martin Alsinet
2017-11-19  7:41         ` Jack Kamm
2017-11-20  6:25           ` Kyle Meyer
2017-11-20 21:31             ` Jack Kamm
2017-11-21  4:04               ` Kyle Meyer
2017-11-21  8:28                 ` Jack Kamm
2017-11-26  2:45                   ` Ista Zahn
2017-11-26  8:25                     ` Jack Kamm
2017-11-26  8:15                   ` Jack Kamm
2017-11-27  4:00                     ` Kyle Meyer
2017-12-09 12:12                       ` John Kamm
2017-12-18  8:22                         ` Jack Kamm
2017-12-18 11:44                           ` Kyle Meyer
2017-12-19  5:11                             ` Kyle Meyer
2017-11-19 17:17     ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).