Juan Reyero <joa...@gmail.com> writes:

[...]
>> --8<---------------cut here---------------start------------->8---
>> ** persistent python
>> #+begin_src python :session :results silent
>>  import types
>> #+end_src
>>
>> #+begin_src python :session
>>  types.FunctionType
>> #+end_src
>>
>> #+resname:
>> : function
>> --8<---------------cut here---------------end--------------->8---
>
> This works, but see what happens with this (no previous src chunks):
>
> #+begin_src python :session :results output
>  2
> #+end_src
>
> #+resname:
> : 2
> : 2

Hi Juan,

Thanks for the org-babel suggestions. However I can't replicate this
behaviour under linux. I get

#+resname:
: 2

for all three examples.

>
> (expected nothing, which is what I get if I remove the :session).

An understandable expectation. In non-session mode, we collect stdout
and if the expression "2" is passed to the interpreter nothing is output
to stdout. However in session mode we collect whatever output appears in
the comint buffer, and if you give the interpreter "2" the interpreter
comes back and prints the value of that expression.

I'm using org-version 6.31trans in emacs-version 23.0.91.1 under ubuntu
jaunty with python 2.6.2. Is this definitely replicable under OSX?

Dan

>
> #+begin_src python :session :results value
>  2
> #+end_src
>
> #+resname:
> : 0
>
> This is how my python buffer looks like after processing this last
> chunk in a fresh session:
>
>>>> import emacs; print '_emacs_out ()'
> /Applications/Emacs.app/Contents/Resources/etc/emacs.py:24:
> DeprecationWarning: the sets module is deprecated
>   from sets import Set
> 2
>
>
> _
> 'org_babel_python_eoe'
> 2
> 2
>>>>
>>>>
>>>> _
> 2
>>>> 'org_babel_python_eoe'
> 'org_babel_python_eoe'
>>>>

>>> 2


_
'org_babel_python_eoe'
2
>>> >>> >>> 2
>>> 'org_babel_python_eoe'
>>> 

>
> But, interestingly, if I return a string instead of a number, as you
> do in your example, it works:
>
> #+begin_src python :session :results value
>  "2"
> #+end_src
>
> #+resname:
> : 2
>
> It is not related to a previous chunk messing up the python
> interpreter.  I have moved to the git version, and it still behaves
> like this.  I am using python 2.6.1.


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to