From: Darlan Cavalcante Moreira <darcamo@gmail.com>
To: org-mode Mailinglist <emacs-orgmode@gnu.org>
Subject: [Babel] Strange bug in org-babel with python
Date: Tue, 10 Nov 2009 20:26:51 -0300 [thread overview]
Message-ID: <4af9f6c1.0504c00a.3ba1.31cc@mx.google.com> (raw)
Hello org-users,
Today I was bitten by a weird behavior when executing some python
blocks with org-babel that really confused me, but after some trying
and error I was able to isolate the problem.
When a block has an import statement such as
,----
| from some_module import *
`----
it works with :results output, but not with :results value.
The content of simple file to reproduce the problem is showed below
--------------- Cut here -----------------------------------
* Test Org-babel
#+begin_src python :tangle test :results silent
def double_input(a):
return a*2
#+end_src
#+begin_src python :results value
import test
def times_four(a):
return test.double_input(a)*2
if __name__ == '__main__':
print "Value is %s" % times_four(10)
times_four(10)
#+end_src
#+begin_src python :results value
from test import *
def times_four(a):
return double_input(a)*2
if __name__ == '__main__':
print "Value is %s" % times_four(10)
times_four(10)
#+end_src
--------------- End of cut ---------------------------------
To reproduce the problem, tangle the file to create test.py from the
first block. Then executing the second block (which has no import *)
works with either :results output or :results value.
However, the third block, (which uses import *) only works if executed
with :results output. I can't see the reason for this since the code
is right and works in a python buffer as expected.
- Darlan
next reply other threads:[~2009-11-10 23:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-10 23:26 Darlan Cavalcante Moreira [this message]
2009-11-12 0:44 ` [Babel] Strange bug in org-babel with python Dan Davison
2009-11-12 2:58 ` Darlan Cavalcante Moreira
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4af9f6c1.0504c00a.3ba1.31cc@mx.google.com \
--to=darcamo@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.