From: Dan Davison <davison@stats.ox.ac.uk>
To: Juan Reyero <joanmg@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Buffer-wide definitions in org-babel
Date: Thu, 08 Oct 2009 10:11:02 -0400 [thread overview]
Message-ID: <87fx9u7z7t.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <55bd243d0910080222q34a7ac79g26a7f9358d806e62@mail.gmail.com> (Juan Reyero's message of "Thu, 8 Oct 2009 11:22:58 +0200")
Juan Reyero <joanmg@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.
next prev parent reply other threads:[~2009-10-08 14:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 14:20 Buffer-wide definitions in org-babel Juan Reyero
2009-10-07 18:48 ` Eric Schulte
2009-10-07 19:17 ` Eric Schulte
2009-10-08 11:16 ` Juan Reyero
2009-10-08 9:22 ` Juan Reyero
2009-10-08 14:11 ` Dan Davison [this message]
2009-10-09 14:53 ` Juan Reyero
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fx9u7z7t.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=emacs-orgmode@gnu.org \
--cc=joanmg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).