Am 29.03.2013 21:10, schrieb Gary Oberbrunner:Hi Gary,
On Fri, Mar 29, 2013 at 11:29 AM, Andreas Röhler <
andreas.roehler@easy-emacs.de> wrote:
IMO org-babel should be able to run source code as is.
If an org-mode specific modification is required at such a trivial form,
what to expect wrt complex environments?
BTW this fails also:
#+begin_src python
print "Hello, world!"
#+end_src python
#+RESULTS:
: None
As the worg doc says, if you want to capture stdout rather than a value,
you need :results output. The default is :results value (which in session
mode is the last expression executed, and in non-session mode is whatever
you return().)
I agree it is a little odd, but given how python works it's not clear to me
how to improve it.
if someone wants the value of the last expression returned, it's much simpler to write Python/native
language, than cryptic, lately documented org-mode flags.
That's a kind of re-inventing a programming-language, also redundant.No? Any program may output any of it's values.
Specifically, in non-session mode, the python
interpreter is run as a separate process and fed the input (with some stuff
around it). There is no way for python to get "the last value" in
non-interactive mode,
The use of "return" doesn't depend from interactive mode.
so instead ob-python wraps your code in a function,
then calls it, and writes the return value of that function to the temp
file. Conversely in session mode, each block is talking to the same
interactive python interpreter, just what you get if you type 'python' at
the shell. So using return() there doesn't make any sense, and wouldn't
work.
It's related to a function.
Seen from org-user, IMO any back-ends interactive mode or not is not of interest.
":session" mimics and/or probably uses it, but it would also possible to implement it as a file, loading
previous values from a storage.Probably most useful at this list is to define which feature/behavior is most convenient.
I don't see any way to make them both behave the same way.
Why people use this mode, what they want to do.