From: Ken Mankoff <mankoff@gmail.com>
To: John Hendy <jw.hendy@gmail.com>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: python :session does return
Date: Thu, 16 Jan 2014 15:14:29 -0500 (EST) [thread overview]
Message-ID: <alpine.OSX.2.00.1401161502220.86074@tbetbambyn.jubv.rqh> (raw)
In-Reply-To: <CA+M2ft8e6Hiwt=vxJo-kV6_kSPDoOLJkPJiVsaPUyn24PVCD9w@mail.gmail.com>
Hi John,
On Wed, 15 Jan 2014, John Hendy wrote:
> On Wed, Jan 15, 2014 at 6:22 AM, Ken Mankoff <mankoff@gmail.com> 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
prev parent reply other threads:[~2014-01-16 20:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 13:38 python :session does return Ken Mankoff
2014-01-14 15:34 ` Ken Mankoff
2014-01-14 16:32 ` Nick Dokos
2014-01-14 17:48 ` Ken Mankoff
2014-01-14 17:55 ` Nick Dokos
2014-01-14 18:25 ` Ken Mankoff
2014-01-14 23:04 ` John Hendy
2014-01-15 12:22 ` Ken Mankoff
2014-01-15 19:01 ` Eric Schulte
2014-01-15 21:08 ` John Hendy
2014-01-16 20:14 ` Ken Mankoff [this message]
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=alpine.OSX.2.00.1401161502220.86074@tbetbambyn.jubv.rqh \
--to=mankoff@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jw.hendy@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).