[O] Fwd: run python from org, draft

2013-03-29 Thread Gary Oberbrunner
[sorry, forgot to reply all -- Gary]

-- Forwarded message --
From: Gary Oberbrunner ga...@oberbrunner.com
Date: Thu, Mar 28, 2013 at 10:43 PM
Subject: Re: [O] run python from org, draft
To: Andreas Röhler andreas.roeh...@easy-emacs.de


Does this assume org-babel-python-mode is set to 'python-mode?  The default
is 'python, I believe.  I don't think you should unconditionally
call py-send-string-return-output like that.

Also, why would you avoid calling org-babel-python-evaluate?  Where in your
patch would it account for the setting of session, result-type or
result-params?



On Thu, Mar 28, 2013 at 5:55 PM, Andreas Röhler 
andreas.roeh...@easy-emacs.de wrote:

 Hi,

 as running python from org-source has been reported broken,
 herewith a patch, which allows basic usage.

 Requires python-mode.el-6.1

 https://launchpad.net/python-**mode/trunk/6.1.1/+download/**
 python-mode.el-6.1.1.tar.gzhttps://launchpad.net/python-mode/trunk/6.1.1/+download/python-mode.el-6.1.1.tar.gz

 Just a draft, not thought as implementation,

 Andreas




-- 
Gary



-- 
Gary


Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Andreas Röhler

Hi Gary,

 Am 29.03.2013 13:11, schrieb Gary Oberbrunner:


Does this assume org-babel-python-mode is set to 'python-mode?  The default
is 'python, I believe.  I don't think you should unconditionally
call py-send-string-return-output like that.

Also, why would you avoid calling org-babel-python-evaluate?  Where in your
patch would it account for the setting of session, result-type or
result-params?




with current

GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-05

Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @ 
MY_PATH/emacs-24.3/lisp/org/)

python from org-source seems completely broken.

For example:

#+BEGIN_SRC python
1+2
#+END_SRC

#+RESULTS:
: None


While the patched ob-python.el at least gives a result.
As attached png shows, a py-shell buffer is visible, which should not.
And some more back-sides. So far following your arguments.

Just wanted to look for the spot where to fix it.
Maybe not the right one yet, just a study.

So let's go on until a convenient solution is found,

Andreas



On Thu, Mar 28, 2013 at 5:55 PM, Andreas Röhler 
andreas.roeh...@easy-emacs.de wrote:


Hi,

as running python from org-source has been reported broken,
herewith a patch, which allows basic usage.

Requires python-mode.el-6.1

https://launchpad.net/python-**mode/trunk/6.1.1/+download/**
python-mode.el-6.1.1.tar.gzhttps://launchpad.net/python-mode/trunk/6.1.1/+download/python-mode.el-6.1.1.tar.gz

Just a draft, not thought as implementation,

Andreas







attachment: ob-python-patched.png

Re: [O] Fwd: run python from org, draft

2013-03-29 Thread John Hendy
On Fri, Mar 29, 2013 at 9:47 AM, Andreas Röhler 
andreas.roeh...@easy-emacs.de wrote:

 Hi Gary,

  Am 29.03.2013 13:11, schrieb Gary Oberbrunner:

  Does this assume org-babel-python-mode is set to 'python-mode?  The
 default
 is 'python, I believe.  I don't think you should unconditionally
 call py-send-string-return-output like that.

 Also, why would you avoid calling org-babel-python-evaluate?  Where in
 your
 patch would it account for the setting of session, result-type or
 result-params?



 with current

 GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-05

 Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
 MY_PATH/emacs-24.3/lisp/org/)

 python from org-source seems completely broken.

 For example:

 #+BEGIN_SRC python
 1+2
 #+END_SRC

 #+RESULTS:
 : None


Weird. With all the testing we did last week, I'm surprised that this is
the case with me as well. I'm also getting no results with Org 8.0-pre and
Emacs 24.3.1.

John



 While the patched ob-python.el at least gives a result.
 As attached png shows, a py-shell buffer is visible, which should not.
 And some more back-sides. So far following your arguments.

 Just wanted to look for the spot where to fix it.
 Maybe not the right one yet, just a study.

 So let's go on until a convenient solution is found,

 Andreas


 On Thu, Mar 28, 2013 at 5:55 PM, Andreas Röhler 
 andreas.roeh...@easy-emacs.de wrote:

  Hi,

 as running python from org-source has been reported broken,
 herewith a patch, which allows basic usage.

 Requires python-mode.el-6.1

 https://launchpad.net/python-mode/trunk/6.1.1/+download/**https://launchpad.net/python-**mode/trunk/6.1.1/+download/**
 python-mode.el-6.1.1.tar.gzht**tps://launchpad.net/python-**
 mode/trunk/6.1.1/+download/**python-mode.el-6.1.1.tar.gzhttps://launchpad.net/python-mode/trunk/6.1.1/+download/python-mode.el-6.1.1.tar.gz
 

 Just a draft, not thought as implementation,

 Andreas








Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte
 with current

 GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-05

 Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
 MY_PATH/emacs-24.3/lisp/org/)

 python from org-source seems completely broken.

 For example:

 #+BEGIN_SRC python
 1+2
 #+END_SRC

 #+RESULTS:
 : None


 Weird. With all the testing we did last week, I'm surprised that this is
 the case with me as well. I'm also getting no results with Org 8.0-pre and
 Emacs 24.3.1.


Because of quirks of the python language, when executing outside of a
session, it is necessary to explicitly specify a return.

For example.

#+begin_src python
  return 1+2
#+end_src

#+RESULTS:
: 3

or

#+begin_src python :return x
  x = 1+2
#+end_src

#+RESULTS:
: 3

This is clearly stated in the Python documentation on Worg.
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

Thanks,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Andreas Röhler

Am 29.03.2013 16:09, schrieb Eric Schulte:

with current

GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-05

Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
MY_PATH/emacs-24.3/lisp/org/)

python from org-source seems completely broken.

For example:

#+BEGIN_SRC python
1+2
#+END_SRC

#+RESULTS:
: None



Weird. With all the testing we did last week, I'm surprised that this is
the case with me as well. I'm also getting no results with Org 8.0-pre and
Emacs 24.3.1.



Because of quirks of the python language,


or rather the quirks of org-babel? ;)

 when executing outside of a

session, it is necessary to explicitly specify a return.

For example.

 #+begin_src python
   return 1+2
 #+end_src

 #+RESULTS:
 : 3

or

 #+begin_src python :return x
   x = 1+2
 #+end_src

 #+RESULTS:
 : 3

This is clearly stated in the Python documentation on Worg.
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

Thanks,



IMO org-babel should be able to run source code as is.
If an org-mode specific modification is required at such a trivial form, what 
to expect wrt complex environments?

BTW this fails also:

#+begin_src python
print Hello, world!
#+end_src python

#+RESULTS:
: None


Can't see a consistent behavior so far.

Why not follow the path given, which avoids the artistics?


Andreas






Re: [O] Fwd: run python from org, draft

2013-03-29 Thread John Hendy
On Fri, Mar 29, 2013 at 10:09 AM, Eric Schulte schulte.e...@gmail.com
wrote:

  with current
 
  GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of
2013-03-05
 
  Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
  MY_PATH/emacs-24.3/lisp/org/)
 
  python from org-source seems completely broken.
 
  For example:
 
  #+BEGIN_SRC python
  1+2
  #+END_SRC
 
  #+RESULTS:
  : None
 
 
  Weird. With all the testing we did last week, I'm surprised that this is
  the case with me as well. I'm also getting no results with Org 8.0-pre
and
  Emacs 24.3.1.
 

 Because of quirks of the python language, when executing outside of a
 session, it is necessary to explicitly specify a return.

 For example.

 #+begin_src python
   return 1+2
 #+end_src

 #+RESULTS:
 : 3

 or

 #+begin_src python :return x
   x = 1+2
 #+end_src

 #+RESULTS:
 : 3

 This is clearly stated in the Python documentation on Worg.
 http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html


This isn't working for me on Org-8.0 (from that Worg page):

#+begin_src python :session
def foo(x):
  if x0:
return x+1
  else:
return x-1

foo(1)
#+end_src

#+RESULTS:
: None



 Thanks,

 --
 Eric Schulte
 http://cs.unm.edu/~eschulte


Re: [O] Fwd: run python from org, draft

2013-03-29 Thread John Hendy
On Fri, Mar 29, 2013 at 10:09 AM, Eric Schulte schulte.e...@gmail.comwrote:

  with current
 
  GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-05
 
  Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
  MY_PATH/emacs-24.3/lisp/org/)
 
  python from org-source seems completely broken.
 
  For example:
 
  #+BEGIN_SRC python
  1+2
  #+END_SRC
 
  #+RESULTS:
  : None
 
 
  Weird. With all the testing we did last week, I'm surprised that this is
  the case with me as well. I'm also getting no results with Org 8.0-pre
 and
  Emacs 24.3.1.
 

 Because of quirks of the python language, when executing outside of a
 session, it is necessary to explicitly specify a return.

 For example.

 #+begin_src python
   return 1+2
 #+end_src

 #+RESULTS:
 : 3

 or

 #+begin_src python :return x
   x = 1+2
 #+end_src

 #+RESULTS:
 : 3

 This is clearly stated in the Python documentation on Worg.
 http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html


This isn't working for me on Org-8.0 (from that Worg page):

#+begin_src python :session
def foo(x):
  if x0:
return x+1
  else:
return x-1

foo(1)
#+end_src

#+RESULTS:
: None

I tend to agree. I don't/haven't used Python, but having now read the
ob-doc-python bit, it seems peculiar/undesirable to have to change
indenting, line breaking, and return statements depending on :session or
not...

John



 Thanks,

 --
 Eric Schulte
 http://cs.unm.edu/~eschulte



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte
Andreas Röhler andreas.roeh...@easy-emacs.de writes:

 Am 29.03.2013 16:09, schrieb Eric Schulte:
 with current

 GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-05

 Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
 MY_PATH/emacs-24.3/lisp/org/)

 python from org-source seems completely broken.

 For example:

 #+BEGIN_SRC python
 1+2
 #+END_SRC

 #+RESULTS:
 : None


 Weird. With all the testing we did last week, I'm surprised that this is
 the case with me as well. I'm also getting no results with Org 8.0-pre and
 Emacs 24.3.1.


 Because of quirks of the python language,

 or rather the quirks of org-babel? ;)

   when executing outside of a
 session, it is necessary to explicitly specify a return.

 For example.

  #+begin_src python
return 1+2
  #+end_src

  #+RESULTS:
  : 3

 or

  #+begin_src python :return x
x = 1+2
  #+end_src

  #+RESULTS:
  : 3

 This is clearly stated in the Python documentation on Worg.
 http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

 Thanks,


 IMO org-babel should be able to run source code as is.

A valid opinion, in fact I think I defended that point of view myself,
and we used to wrap python code in a function so that we could easily
return the result of the block without an explicit return statement.
However people who use Python more than myself argued for the current
behavior and made a convincing point.  Please look back through the
mailing list archives to see the discussion if you're not convinced.

 
 If an org-mode specific modification is required at such a trivial
 form, what to expect wrt complex environments?


People have been using Org-mode's code block support for years, often in
complex environments.  However they tend to get along better if they
read the documentation.


 BTW this fails also:

 #+begin_src python
 print Hello, world!
 #+end_src python

 #+RESULTS:
 : None


Because it does not return any value, and you are asking for the value,
if you add :results output to the header of that code block you'll get
what you appear to expect.  I acknowledge that there are a host of
header arguments and things to learn (value vs. output, language
specific quirks etc...) to enable sophisticated use of code blocks in
Org-mode.  The best way to learn this stuff is through the
documentation, *not* through repeatedly sending non working examples to
the mailing list.



 Can't see a consistent behavior so far.

 Why not follow the path given, which avoids the artistics?


I don't understand this last sentences at all.



 Andreas




-- 
Eric Schulte
http://cs.unm.edu/~eschulte



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte
John Hendy jw.he...@gmail.com writes:

 On Fri, Mar 29, 2013 at 10:09 AM, Eric Schulte schulte.e...@gmail.comwrote:

  with current
 
  GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-05
 
  Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @
  MY_PATH/emacs-24.3/lisp/org/)
 
  python from org-source seems completely broken.
 
  For example:
 
  #+BEGIN_SRC python
  1+2
  #+END_SRC
 
  #+RESULTS:
  : None
 
 
  Weird. With all the testing we did last week, I'm surprised that this is
  the case with me as well. I'm also getting no results with Org 8.0-pre
 and
  Emacs 24.3.1.
 

 Because of quirks of the python language, when executing outside of a
 session, it is necessary to explicitly specify a return.

 For example.

 #+begin_src python
   return 1+2
 #+end_src

 #+RESULTS:
 : 3

 or

 #+begin_src python :return x
   x = 1+2
 #+end_src

 #+RESULTS:
 : 3

 This is clearly stated in the Python documentation on Worg.
 http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html


 This isn't working for me on Org-8.0 (from that Worg page):

 #+begin_src python :session
 def foo(x):
   if x0:
 return x+1
   else:
 return x-1

 foo(1)
 #+end_src

 #+RESULTS:
 : None


As we've proven a couple of times now, Python session are broken with
the newest version of Emacs (since the upstream change to an entirely
new python.el implementation).  That is the cause of your example above.


 I tend to agree. I don't/haven't used Python, but having now read the
 ob-doc-python bit, it seems peculiar/undesirable to have to change
 indenting, line breaking, and return statements depending on :session or
 not...


I'd refer you to the previous discussion on the mailing list.  I
personally don't use Python and don't care, but others who have used
Python more extensively than you or I argued for the existing behavior,
so I'd rather not change it back capriciously.

Thanks,


 John



 Thanks,

 --
 Eric Schulte
 http://cs.unm.edu/~eschulte


-- 
Eric Schulte
http://cs.unm.edu/~eschulte



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte
 As we've proven a couple of times now, Python session are broken with
 the newest version of Emacs (since the upstream change to an entirely
 new python.el implementation).

I've just pushed up a fix to ob-python.el so that sessions should now
work with the latest version of Emacs.  I hope this clears up some of
the miss-understandings surrounding ob-python.

Here is a quick example usage.

#+Title: Python Sessions

Works with an un-named session.
#+begin_src python :session
  x = 1 + 2
  x
#+end_src

#+RESULTS:
: 3

#+begin_src python :session
  x
#+end_src

#+RESULTS:
: 3

Works with a named session.
#+begin_src python :session foo
  x = 9
  x
#+end_src

#+RESULTS:
: 9

#+begin_src python :session foo
  x
#+end_src

#+RESULTS:
: 9

Notice that the un-named session still has the desired value.
#+begin_src python :session
x
#+end_src

#+RESULTS:
: 3

-- 
Eric Schulte
http://cs.unm.edu/~eschulte


Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Andreas Röhler

Am 29.03.2013 17:20, schrieb Eric Schulte:


A valid opinion, in fact I think I defended that point of view myself,


Hi Eric,

so, if I'm saying: let's make things considerably easier, working right from 
the spot,
why not try that?

What I need still is a specification, what :session and the other header 
arguments shall do.
Presently they do quite different things. Also can't read a bulk of mails to 
figure out some guessing.

Please write a specification and with the help of the other guys let's have 
some tiny and
effective ob-python.

Let's see of we need more lines than ob-emacs-lisp.el :)

Cheers



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte
Andreas Röhler andreas.roeh...@easy-emacs.de writes:

 Am 29.03.2013 17:20, schrieb Eric Schulte:

 A valid opinion, in fact I think I defended that point of view myself,

 Hi Eric,

 so, if I'm saying: let's make things considerably easier, working right from 
 the spot,
 why not try that?

 What I need still is a specification, what :session and the other header 
 arguments shall do.
 Presently they do quite different things. Also can't read a bulk of mails to 
 figure out some guessing.

 Please write a specification and with the help of the other guys let's have 
 some tiny and
 effective ob-python.


Sorry, I'm not going to do this work for you.  If you want to take a
shot at re-working ob-python, then you're welcome to.  However, I would
recommend first reading through some of the history which lead to its
current state, and fully understanding what that current state is (which
at a minimum means reading and digesting the relevant documentation).

 Let's see of we need more lines than ob-emacs-lisp.el :)


You will. :)

Best of luck,


 Cheers

-- 
Eric Schulte
http://cs.unm.edu/~eschulte



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Evan Misshula
Org-mode version 8.0-pre (release_8.0-pre-203-g993e3e @
/home/evan/Documents/org/elisp/org-mode/lisp/)
GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10) of
2013-03-21 on evan-Dell-System-Inspiron-N7110 [2 times]

I installed the patched version.  It does hold session definition:

#+name: second-deriv-function
#+begin_src python :session  :results output :exports code
  def diff2(f, x, h=1E-6):
Function that takes the second derivative
r=(f(x-h)-2*f(x)+f(x+h))/float(h*h)
return r

#+end_src
#+RESULTS: second-deriv-function

Now let's write a target function, say $g(t)=t^{-6}$:
#+name: target-funtion
#+begin_src python :session :results output :exports code
  def g(t):
  well behaved target function
  return t**(-6)

#+end_src

#+RESULTS: target-funtion

Now let's define the second derivative and evaluate it at $t=1.2$

#+name: evaluating-the-target
#+begin_src python :session  :results output :exports both
  t=1.2
  d2g = diff2(g,t)
  print g''(%f)=%f % (t, d2g)
#+end_src

#+RESULTS: evaluating-the-target
:
:  g''(1.20)=9.767798

But it does not appear to support named session:

Works with a named session.
#+begin_src python :session foo
  x = 9
  x
#+end_src

#+RESULTS:
: None

#+begin_src python :session foo
  x
#+end_src

#+RESULTS:

Thanks,

Evan



On Fri, Mar 29, 2013 at 12:59 PM, Eric Schulte schulte.e...@gmail.comwrote:

 Andreas Röhler andreas.roeh...@easy-emacs.de writes:

  Am 29.03.2013 17:20, schrieb Eric Schulte:
 
  A valid opinion, in fact I think I defended that point of view myself,
 
  Hi Eric,
 
  so, if I'm saying: let's make things considerably easier, working right
 from the spot,
  why not try that?
 
  What I need still is a specification, what :session and the other header
 arguments shall do.
  Presently they do quite different things. Also can't read a bulk of
 mails to figure out some guessing.
 
  Please write a specification and with the help of the other guys let's
 have some tiny and
  effective ob-python.
 

 Sorry, I'm not going to do this work for you.  If you want to take a
 shot at re-working ob-python, then you're welcome to.  However, I would
 recommend first reading through some of the history which lead to its
 current state, and fully understanding what that current state is (which
 at a minimum means reading and digesting the relevant documentation).

  Let's see of we need more lines than ob-emacs-lisp.el :)
 

 You will. :)

 Best of luck,

 
  Cheers

 --
 Eric Schulte
 http://cs.unm.edu/~eschulte




-- 
Evan Misshula
Doctoral Student (Criminal Justice)
CUNY John Jay
Let us reform our schools, and we shall find little reform needed in our
prisons.
   John Ruskin, Unto This Last, essay 2 (1862)
   English critic, essayist,  reformer (1819 - 1900)

Instruction does much, but encouragement does everything. Johann Wolfgang
Von Goethe
www.snrg-nyc.org


Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte

 But it does not appear to support named session:

 Works with a named session.
 #+begin_src python :session foo
   x = 9
   x
 #+end_src

 #+RESULTS:
 : None

 #+begin_src python :session foo
   x
 #+end_src

 #+RESULTS:

 Thanks,

 Evan


Thanks for reporting this, I've just pushed up a fix, please let me know
if the problem persists.

Best,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Evan Misshula
It works exactly as advertised for me.  Many thanks!!


On Fri, Mar 29, 2013 at 2:50 PM, Eric Schulte schulte.e...@gmail.comwrote:

 
  But it does not appear to support named session:
 
  Works with a named session.
  #+begin_src python :session foo
x = 9
x
  #+end_src
 
  #+RESULTS:
  : None
 
  #+begin_src python :session foo
x
  #+end_src
 
  #+RESULTS:
 
  Thanks,
 
  Evan
 

 Thanks for reporting this, I've just pushed up a fix, please let me know
 if the problem persists.

 Best,

 --
 Eric Schulte
 http://cs.unm.edu/~eschulte




-- 
Evan Misshula
Doctoral Student (Criminal Justice)
CUNY John Jay
Let us reform our schools, and we shall find little reform needed in our
prisons.
   John Ruskin, Unto This Last, essay 2 (1862)
   English critic, essayist,  reformer (1819 - 1900)

Instruction does much, but encouragement does everything. Johann Wolfgang
Von Goethe
www.snrg-nyc.org


Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Andreas Röhler

Am 29.03.2013 17:47, schrieb Eric Schulte:

As we've proven a couple of times now, Python session are broken with
the newest version of Emacs (since the upstream change to an entirely
new python.el implementation).


I've just pushed up a fix to ob-python.el so that sessions should now
work with the latest version of Emacs.  I hope this clears up some of
the miss-understandings surrounding ob-python.

Here is a quick example usage.






Hi Eric,

you are heading into the wrong direction, while babel as such certainly is of 
great interest.

Recent  ob-python.el commit tells about fixing the buffer name,
change the default python buffer name
How ob-python.el knows about a python buffer name at all?

Python buffer names are at the choice of users, for example via defcustom...
And so on. ob-python.el needs a re-thinking from the bottom, otherwise it 
remains buggy,
only working from case to case.

Andreas




Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Gary Oberbrunner
On Fri, Mar 29, 2013 at 11:09 AM, Eric Schulte schulte.e...@gmail.comwrote:


 Because of quirks of the python language, when executing outside of a
 session, it is necessary to explicitly specify a return.
 ...

 This is clearly stated in the Python documentation on Worg.
 http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html


... which I just wrote!  Glad it's already useful! :-)

I think in any case you will need my recent patch if you want to use
session mode.

If testing is holding up application of my patch, I can test it on Linux
and Mac.

-- 
Gary


Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Andreas Röhler

Am 29.03.2013 17:47, schrieb Eric Schulte:

As we've proven a couple of times now, Python session are broken with
the newest version of Emacs (since the upstream change to an entirely
new python.el implementation).


I've just pushed up a fix to ob-python.el so that sessions should now
work with the latest version of Emacs.  I hope this clears up some of
the miss-understandings surrounding ob-python.

Here is a quick example usage.






Nonewithstanding, really a pleasure seeing it finally working so far.

Thanks!

Andreas



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Andreas Röhler

Am 29.03.2013 20:59, schrieb Gary Oberbrunner:

On Fri, Mar 29, 2013 at 11:09 AM, Eric Schulte schulte.e...@gmail.comwrote:



Because of quirks of the python language, when executing outside of a
session, it is necessary to explicitly specify a return.
...

This is clearly stated in the Python documentation on Worg.
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html



... which I just wrote!  Glad it's already useful! :-)



Ah, thanks a lot! Really helpful.

Apropos for

subtypes:

raw: value is inserted directly

may you give some example there, how to write them?


I think in any case you will need my recent patch if you want to use
session mode.



IIUC it's addressed resp. implemented already w/
993e3ee6215764f122b62cc9c949299b50e1eb22
org-babel-python-with-earmufs

However, ob-python should not fix python-modes but read them... use them...

Anyway, glad to see it's moving,

Andreas


If testing is holding up application of my patch, I can test it on Linux
and Mac.






Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte
Gary Oberbrunner ga...@oberbrunner.com writes:

 On Fri, Mar 29, 2013 at 11:09 AM, Eric Schulte schulte.e...@gmail.comwrote:


 Because of quirks of the python language, when executing outside of a
 session, it is necessary to explicitly specify a return.
 ...

 This is clearly stated in the Python documentation on Worg.
 http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html


 ... which I just wrote!  Glad it's already useful! :-)


Ah, that's great.  Thanks!


 I think in any case you will need my recent patch if you want to use
 session mode.

 If testing is holding up application of my patch, I can test it on Linux
 and Mac.

Hi Gary,

I just looked at your patch (sorry I missed it earlier).  My recent
changes do many of the same things (namely let-binding
`python-shell-buffer-name').

Everything is working currently (at least on Linux).  From reading your
post it sounds like -i must be added to the python command on windows.
I just pushed up that added functionality, can you let me know if
anything else needs to be done to get this working on windows?

Thanks,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte



Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Gary Oberbrunner
Thanks, Eric.

The -i is definitely needed on Windows, I just retested without it and it
hangs.  With your latest fix, it works again.

I think there's a bug in your patch though; line 211 refers to a
nonexistent function org-babel-python-earmufs.  I think you mean
-with-earmufs?


-- 
Gary


Re: [O] Fwd: run python from org, draft

2013-03-29 Thread Eric Schulte
Gary Oberbrunner ga...@oberbrunner.com writes:

 Thanks, Eric.

 The -i is definitely needed on Windows, I just retested without it and it
 hangs.  With your latest fix, it works again.

 I think there's a bug in your patch though; line 211 refers to a
 nonexistent function org-babel-python-earmufs.  I think you mean
 -with-earmufs?

Fixed.  Thanks again!

-- 
Eric Schulte
http://cs.unm.edu/~eschulte