[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] python :session does return
From: |
Ken Mankoff |
Subject: |
Re: [O] python :session does return |
Date: |
Thu, 16 Jan 2014 15:14:29 -0500 (EST) |
User-agent: |
Alpine 2.00 (OSX 1167 2008-08-23) |
Hi John,
On Wed, 15 Jan 2014, John Hendy wrote:
On Wed, Jan 15, 2014 at 6:22 AM, Ken Mankoff <address@hidden> wrote:
Are my results contrary to what's been happening to you?
Actually things now seem to be working. All cases. No hanging when I
run Python in a session, and return and print work when running
IPython. I wrote a test example, load it with emacs -q and then load a
minimal org setup in a code block (I think I'm just starting to get
the hang of some basic lisp and tangling code in Org). I've tried all
possible cases (yes/no session, and results of default/output/value)
and it all seems to be working. I then repeated it all with IPython
instead of default Python.
Output results are a bit ugly when using IPython. If I get a chance
I'll look into the code. Since regular python output doesn't print the
startup info, I assume the same can be done for IPython. It should
just ignore everything until the first "In [1]:" text appears.
Perhaps the previous issues were due to a complicated org setup.
Test file follows.
Cheers,
-k.
* Intro
This is a test file for Python + Emacs. I'm loading this file running
"emacs -q test.org" to try to simplify the setup
** Setup For running Python and other stuff
#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil) ;; don't ask to eval code
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(sh . t)
(emacs-lisp . t)
))
#+END_SRC
#+RESULTS:
| (python . t) | (sh . t) | (emacs-lisp . t) |
** System setup:
#+BEGIN_SRC sh :results output
/usr/local/bin/emacs --version
uname -a
python -V # no ouput for some reason...
# Python 2.7.3 -- 64-bit
#+END_SRC
#+RESULTS:
: GNU Emacs 24.3.1
: Darwin 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013;
xnu-2422.1.72~6/RELEASE_X86_64 x86_64
* Testing
There are two tests per :output and per :session option.
1. 'foo' equal to 'print foo'
2. 'print foo'.
** No Session
**** No Session, No Results
#+BEGIN_SRC python
print 'No Session, No Result'
#+END_SRC
#+RESULTS:
: None
#+BEGIN_SRC python
return 'No Session, No Result'
#+END_SRC
#+RESULTS:
: No Session, No Result
**** No Session, Result Output
#+BEGIN_SRC python :results output
print 'No Session, Result Output'
#+END_SRC
#+RESULTS:
*Warning: Does not run*
#+BEGIN_SRC python :results output
return 'No Session, Result Output'
#+END_SRC
#+RESULTS:
**** No Session, Result Value
#+BEGIN_SRC python :results value
print 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: None
#+BEGIN_SRC python :results value
return 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: No Session, Result Value
** Yes Session
**** Yes Session, No Results
#+BEGIN_SRC python :session foo
print 'No Session, No Result'
#+END_SRC
#+RESULTS:
: None
#+BEGIN_SRC python :session foo
return 'No Session, No Result'
#+END_SRC
#+RESULTS:
: No Session, No Result
**** Yes Session, Result Output
#+BEGIN_SRC python :results output :session foo
print 'No Session, Result Output'
#+END_SRC
#+RESULTS:
*Warning: Does not run*
#+BEGIN_SRC python :results output :session foo
return 'No Session, Result Output'
#+END_SRC
#+RESULTS:
**** Yes Session, Result Value
#+BEGIN_SRC python :results value :session foo
print 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: None
#+BEGIN_SRC python :results value :session foo
return 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: No Session, Result Value
* Second Try with IPython
Execute the following and re-run the test code above.
#+BEGIN_SRC emacs-lisp
(setq org-babel-python-command "ipython --pylab --pdb --nosep")
#+END_SRC
#+RESULTS:
: ipython --pylab --pdb --nosep