* run python from org, draft
@ 2013-03-28 21:55 Andreas Röhler
[not found] ` <CAFChFyjZyxcnH1_jSWEUgXNkvJ0c3F8f4ojQa_EtPov2TjtziQ@mail.gmail.com>
0 siblings, 1 reply; 27+ messages in thread
From: Andreas Röhler @ 2013-03-28 21:55 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 278 bytes --]
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.gz
Just a draft, not thought as implementation,
Andreas
[-- Attachment #2: ob-python.el.patch --]
[-- Type: text/x-patch, Size: 755 bytes --]
diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 7bc9a1f..2734bff 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -86,8 +86,11 @@ This function is called by `org-babel-execute-src-block'."
(org-babel-expand-body:generic
(concat body (if return-val (format "\nreturn %s" return-val) ""))
params (org-babel-variable-assignments:python params)))
- (result (org-babel-python-evaluate
- session full-body result-type result-params preamble)))
+ (result
+ (py-send-string-return-output full-body)
+ ;; (org-babel-python-evaluate
+ ;; session full-body result-type result-params preamble)
+ ))
(org-babel-reassemble-table
result
(org-babel-pick-name (cdr (assoc :colname-names params))
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Fwd: run python from org, draft
[not found] ` <CAFChFyjZyxcnH1_jSWEUgXNkvJ0c3F8f4ojQa_EtPov2TjtziQ@mail.gmail.com>
@ 2013-03-29 12:11 ` Gary Oberbrunner
2013-03-29 14:47 ` Andreas Röhler
0 siblings, 1 reply; 27+ messages in thread
From: Gary Oberbrunner @ 2013-03-29 12:11 UTC (permalink / raw)
To: Orgmode Mailing List
[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]
[sorry, forgot to "reply all" -- Gary]
---------- Forwarded message ----------
From: Gary Oberbrunner <garyo@oberbrunner.com>
Date: Thu, Mar 28, 2013 at 10:43 PM
Subject: Re: [O] run python from org, draft
To: Andreas Röhler <andreas.roehler@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.roehler@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.gz<https://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
[-- Attachment #2: Type: text/html, Size: 1966 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 12:11 ` Fwd: " Gary Oberbrunner
@ 2013-03-29 14:47 ` Andreas Röhler
2013-03-29 14:57 ` John Hendy
0 siblings, 1 reply; 27+ messages in thread
From: Andreas Röhler @ 2013-03-29 14:47 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Gary Oberbrunner
[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]
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.roehler@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.gz<https://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 #2: ob-python-patched.png --]
[-- Type: image/png, Size: 33789 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 14:47 ` Andreas Röhler
@ 2013-03-29 14:57 ` John Hendy
2013-03-29 15:09 ` Eric Schulte
0 siblings, 1 reply; 27+ messages in thread
From: John Hendy @ 2013-03-29 14:57 UTC (permalink / raw)
To: Andreas Röhler; +Cc: Gary Oberbrunner, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]
On Fri, Mar 29, 2013 at 9:47 AM, Andreas Röhler <
andreas.roehler@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.roehler@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.gz<ht**tps://launchpad.net/python-**
>>> mode/trunk/6.1.1/+download/**python-mode.el-6.1.1.tar.gz<https://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 #2: Type: text/html, Size: 3292 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 14:57 ` John Hendy
@ 2013-03-29 15:09 ` Eric Schulte
2013-03-29 15:29 ` Andreas Röhler
` (3 more replies)
0 siblings, 4 replies; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 15:09 UTC (permalink / raw)
To: John Hendy; +Cc: emacs-orgmode, Gary Oberbrunner
>> 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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 15:09 ` Eric Schulte
@ 2013-03-29 15:29 ` Andreas Röhler
2013-03-29 16:20 ` Eric Schulte
[not found] ` <CAFChFyhRbz6hh-NyOZTfdKJcTPh=F3J=07k2fR9p+A9Wig_pRA@mail.gmail.com>
2013-03-29 15:35 ` John Hendy
` (2 subsequent siblings)
3 siblings, 2 replies; 27+ messages in thread
From: Andreas Röhler @ 2013-03-29 15:29 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Gary Oberbrunner
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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 15:09 ` Eric Schulte
2013-03-29 15:29 ` Andreas Röhler
@ 2013-03-29 15:35 ` John Hendy
[not found] ` <CAFChFyhOrPVS2E5CE9H2+zX5TFV4D-themQbjx2DaSx-WmG14g@mail.gmail.com>
2013-03-29 15:50 ` John Hendy
2013-03-29 19:59 ` Gary Oberbrunner
3 siblings, 1 reply; 27+ messages in thread
From: John Hendy @ 2013-03-29 15:35 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Gary Oberbrunner
[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]
On Fri, Mar 29, 2013 at 10:09 AM, Eric Schulte <schulte.eric@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 x>0:
return x+1
else:
return x-1
foo(1)
#+end_src
#+RESULTS:
: None
>
> Thanks,
>
> --
> Eric Schulte
> http://cs.unm.edu/~eschulte
[-- Attachment #2: Type: text/html, Size: 2264 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 15:09 ` Eric Schulte
2013-03-29 15:29 ` Andreas Röhler
2013-03-29 15:35 ` John Hendy
@ 2013-03-29 15:50 ` John Hendy
2013-03-29 16:23 ` Eric Schulte
2013-03-29 19:59 ` Gary Oberbrunner
3 siblings, 1 reply; 27+ messages in thread
From: John Hendy @ 2013-03-29 15:50 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Gary Oberbrunner
[-- Attachment #1: Type: text/plain, Size: 1599 bytes --]
On Fri, Mar 29, 2013 at 10:09 AM, Eric Schulte <schulte.eric@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 x>0:
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
>
[-- Attachment #2: Type: text/html, Size: 2981 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 15:29 ` Andreas Röhler
@ 2013-03-29 16:20 ` Eric Schulte
2013-03-29 16:49 ` Andreas Röhler
[not found] ` <CAFChFyhRbz6hh-NyOZTfdKJcTPh=F3J=07k2fR9p+A9Wig_pRA@mail.gmail.com>
1 sibling, 1 reply; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 16:20 UTC (permalink / raw)
To: Andreas Röhler; +Cc: emacs-orgmode, Gary Oberbrunner
Andreas Röhler <andreas.roehler@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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 15:50 ` John Hendy
@ 2013-03-29 16:23 ` Eric Schulte
2013-03-29 16:47 ` Eric Schulte
0 siblings, 1 reply; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 16:23 UTC (permalink / raw)
To: John Hendy; +Cc: emacs-orgmode, Gary Oberbrunner
John Hendy <jw.hendy@gmail.com> writes:
> On Fri, Mar 29, 2013 at 10:09 AM, Eric Schulte <schulte.eric@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 x>0:
> 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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 16:23 ` Eric Schulte
@ 2013-03-29 16:47 ` Eric Schulte
2013-03-29 19:06 ` Andreas Röhler
2013-03-29 20:04 ` Andreas Röhler
0 siblings, 2 replies; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 16:47 UTC (permalink / raw)
To: John Hendy; +Cc: emacs-orgmode, Gary Oberbrunner
[-- Attachment #1: Type: text/plain, Size: 398 bytes --]
> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: example.org --]
[-- Type: text/x-org, Size: 468 bytes --]
#+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
[-- Attachment #3: Type: text/plain, Size: 46 bytes --]
--
Eric Schulte
http://cs.unm.edu/~eschulte
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 16:20 ` Eric Schulte
@ 2013-03-29 16:49 ` Andreas Röhler
2013-03-29 16:59 ` Eric Schulte
0 siblings, 1 reply; 27+ messages in thread
From: Andreas Röhler @ 2013-03-29 16:49 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Gary Oberbrunner
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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 16:49 ` Andreas Röhler
@ 2013-03-29 16:59 ` Eric Schulte
2013-03-29 18:33 ` Evan Misshula
0 siblings, 1 reply; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 16:59 UTC (permalink / raw)
To: Andreas Röhler; +Cc: emacs-orgmode, Gary Oberbrunner
Andreas Röhler <andreas.roehler@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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 16:59 ` Eric Schulte
@ 2013-03-29 18:33 ` Evan Misshula
2013-03-29 18:50 ` Eric Schulte
0 siblings, 1 reply; 27+ messages in thread
From: Evan Misshula @ 2013-03-29 18:33 UTC (permalink / raw)
To: Eric Schulte; +Cc: Gary Oberbrunner, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3116 bytes --]
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.200000)=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.eric@gmail.com>wrote:
> Andreas Röhler <andreas.roehler@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
[-- Attachment #2: Type: text/html, Size: 4174 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 18:33 ` Evan Misshula
@ 2013-03-29 18:50 ` Eric Schulte
2013-03-29 19:04 ` Evan Misshula
0 siblings, 1 reply; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 18:50 UTC (permalink / raw)
To: Evan Misshula; +Cc: Gary Oberbrunner, emacs-orgmode
>
> 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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 18:50 ` Eric Schulte
@ 2013-03-29 19:04 ` Evan Misshula
0 siblings, 0 replies; 27+ messages in thread
From: Evan Misshula @ 2013-03-29 19:04 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 978 bytes --]
It works exactly as advertised for me. Many thanks!!
On Fri, Mar 29, 2013 at 2:50 PM, Eric Schulte <schulte.eric@gmail.com>wrote:
> >
> > 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
[-- Attachment #2: Type: text/html, Size: 1704 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 16:47 ` Eric Schulte
@ 2013-03-29 19:06 ` Andreas Röhler
2013-03-29 20:04 ` Andreas Röhler
1 sibling, 0 replies; 27+ messages in thread
From: Andreas Röhler @ 2013-03-29 19:06 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Gary Oberbrunner
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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 15:09 ` Eric Schulte
` (2 preceding siblings ...)
2013-03-29 15:50 ` John Hendy
@ 2013-03-29 19:59 ` Gary Oberbrunner
2013-03-29 20:15 ` Andreas Röhler
2013-03-29 20:25 ` Eric Schulte
3 siblings, 2 replies; 27+ messages in thread
From: Gary Oberbrunner @ 2013-03-29 19:59 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
On Fri, Mar 29, 2013 at 11:09 AM, Eric Schulte <schulte.eric@gmail.com>wrote:
>
> 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
[-- Attachment #2: Type: text/html, Size: 1161 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 16:47 ` Eric Schulte
2013-03-29 19:06 ` Andreas Röhler
@ 2013-03-29 20:04 ` Andreas Röhler
1 sibling, 0 replies; 27+ messages in thread
From: Andreas Röhler @ 2013-03-29 20:04 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode, Gary Oberbrunner
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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Fwd: Fwd: run python from org, draft
[not found] ` <CAFChFyhRbz6hh-NyOZTfdKJcTPh=F3J=07k2fR9p+A9Wig_pRA@mail.gmail.com>
@ 2013-03-29 20:10 ` Gary Oberbrunner
2013-03-29 20:58 ` Andreas Röhler
0 siblings, 1 reply; 27+ messages in thread
From: Gary Oberbrunner @ 2013-03-29 20:10 UTC (permalink / raw)
To: Orgmode Mailing List
[-- Attachment #1: Type: text/plain, Size: 1379 bytes --]
On Fri, Mar 29, 2013 at 11:29 AM, Andreas Röhler <
andreas.roehler@easy-emacs.de> wrote:
> 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
>
As the worg doc says, if you want to capture stdout rather than a value,
you need :results output. The default is :results value (which in session
mode is the last expression executed, and in non-session mode is whatever
you return().)
I agree it is a little odd, but given how python works it's not clear to me
how to improve it. Specifically, in non-session mode, the python
interpreter is run as a separate process and fed the input (with some stuff
around it). There is no way for python to get "the last value" in
non-interactive mode, so instead ob-python wraps your code in a function,
then calls it, and writes the return value of that function to the temp
file. Conversely in session mode, each block is talking to the same
interactive python interpreter, just what you get if you type 'python' at
the shell. So using return() there doesn't make any sense, and wouldn't
work. I don't see any way to make them both behave the same way.
--
Gary
[-- Attachment #2: Type: text/html, Size: 1969 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Fwd: Fwd: run python from org, draft
[not found] ` <CAFChFyhOrPVS2E5CE9H2+zX5TFV4D-themQbjx2DaSx-WmG14g@mail.gmail.com>
@ 2013-03-29 20:11 ` Gary Oberbrunner
0 siblings, 0 replies; 27+ messages in thread
From: Gary Oberbrunner @ 2013-03-29 20:11 UTC (permalink / raw)
To: Orgmode Mailing List
[-- Attachment #1: Type: text/plain, Size: 436 bytes --]
On Fri, Mar 29, 2013 at 11:35 AM, John Hendy <jw.hendy@gmail.com> wrote:
>
> This isn't working for me on Org-8.0 (from that Worg page):
>
> #+begin_src python :session
> def foo(x):
> if x>0:
> return x+1
> else:
> return x-1
>
> foo(1)
> #+end_src
>
> #+RESULTS:
> : None
>
> Try applying my patch from this list a few days ago; I think it will work
then. Without it, session mode is totally broken (I think).
--
Gary
[-- Attachment #2: Type: text/html, Size: 1020 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 19:59 ` Gary Oberbrunner
@ 2013-03-29 20:15 ` Andreas Röhler
2013-03-29 20:25 ` Eric Schulte
1 sibling, 0 replies; 27+ messages in thread
From: Andreas Röhler @ 2013-03-29 20:15 UTC (permalink / raw)
To: Gary Oberbrunner; +Cc: emacs-orgmode, Eric Schulte
Am 29.03.2013 20:59, schrieb Gary Oberbrunner:
> On Fri, Mar 29, 2013 at 11:09 AM, Eric Schulte <schulte.eric@gmail.com>wrote:
>
>>
>> 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.
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 19:59 ` Gary Oberbrunner
2013-03-29 20:15 ` Andreas Röhler
@ 2013-03-29 20:25 ` Eric Schulte
2013-03-29 20:45 ` Gary Oberbrunner
1 sibling, 1 reply; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 20:25 UTC (permalink / raw)
To: Gary Oberbrunner; +Cc: emacs-orgmode
Gary Oberbrunner <garyo@oberbrunner.com> writes:
> On Fri, Mar 29, 2013 at 11:09 AM, Eric Schulte <schulte.eric@gmail.com>wrote:
>
>>
>> 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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 20:25 ` Eric Schulte
@ 2013-03-29 20:45 ` Gary Oberbrunner
2013-03-29 21:13 ` Eric Schulte
0 siblings, 1 reply; 27+ messages in thread
From: Gary Oberbrunner @ 2013-03-29 20:45 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 292 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 417 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: Fwd: run python from org, draft
2013-03-29 20:10 ` Fwd: " Gary Oberbrunner
@ 2013-03-29 20:58 ` Andreas Röhler
2013-03-31 20:04 ` Gary Oberbrunner
0 siblings, 1 reply; 27+ messages in thread
From: Andreas Röhler @ 2013-03-29 20:58 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Gary Oberbrunner, Eric Schulte
Am 29.03.2013 21:10, schrieb Gary Oberbrunner:
> On Fri, Mar 29, 2013 at 11:29 AM, Andreas Röhler <
> andreas.roehler@easy-emacs.de> wrote:
>
>> 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
>>
>
> As the worg doc says, if you want to capture stdout rather than a value,
> you need :results output. The default is :results value (which in session
> mode is the last expression executed, and in non-session mode is whatever
> you return().)
>
> I agree it is a little odd, but given how python works it's not clear to me
> how to improve it.
Hi Gary,
if someone wants the value of the last expression returned, it's much simpler to write Python/native
language, than cryptic, lately documented org-mode flags.
That's a kind of re-inventing a programming-language, also redundant.
Specifically, in non-session mode, the python
> interpreter is run as a separate process and fed the input (with some stuff
> around it). There is no way for python to get "the last value" in
> non-interactive mode,
No? Any program may output any of it's values.
> so instead ob-python wraps your code in a function,
> then calls it, and writes the return value of that function to the temp
> file. Conversely in session mode, each block is talking to the same
> interactive python interpreter, just what you get if you type 'python' at
> the shell. So using return() there doesn't make any sense, and wouldn't
> work.
The use of "return" doesn't depend from interactive mode.
It's related to a function.
Seen from org-user, IMO any back-ends interactive mode or not is not of interest.
":session" mimics and/or probably uses it, but it would also possible to implement it as a file, loading
previous values from a storage.
I don't see any way to make them both behave the same way.
>
Probably most useful at this list is to define which feature/behavior is most convenient.
Why people use this mode, what they want to do.
Cheers,
Andreas
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: run python from org, draft
2013-03-29 20:45 ` Gary Oberbrunner
@ 2013-03-29 21:13 ` Eric Schulte
0 siblings, 0 replies; 27+ messages in thread
From: Eric Schulte @ 2013-03-29 21:13 UTC (permalink / raw)
To: Gary Oberbrunner; +Cc: emacs-orgmode
Gary Oberbrunner <garyo@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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: Fwd: Fwd: run python from org, draft
2013-03-29 20:58 ` Andreas Röhler
@ 2013-03-31 20:04 ` Gary Oberbrunner
0 siblings, 0 replies; 27+ messages in thread
From: Gary Oberbrunner @ 2013-03-31 20:04 UTC (permalink / raw)
To: Andreas Röhler; +Cc: Orgmode Mailing List, Eric Schulte
[-- Attachment #1: Type: text/plain, Size: 2553 bytes --]
On Fri, Mar 29, 2013 at 4:58 PM, Andreas Röhler <
andreas.roehler@easy-emacs.de> wrote:
> Am 29.03.2013 21:10, schrieb Gary Oberbrunner:
>
> On Fri, Mar 29, 2013 at 11:29 AM, Andreas Röhler <
>> andreas.roehler@easy-emacs.de> wrote:
>>
>> 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
>>>
>>>
>> As the worg doc says, if you want to capture stdout rather than a value,
>> you need :results output. The default is :results value (which in session
>> mode is the last expression executed, and in non-session mode is whatever
>> you return().)
>>
>> I agree it is a little odd, but given how python works it's not clear to
>> me
>> how to improve it.
>>
>
> Hi Gary,
>
> if someone wants the value of the last expression returned, it's much
> simpler to write Python/native
> language, than cryptic, lately documented org-mode flags.
> That's a kind of re-inventing a programming-language, also redundant.
>
> Specifically, in non-session mode, the python
>
>> interpreter is run as a separate process and fed the input (with some
>> stuff
>> around it). There is no way for python to get "the last value" in
>> non-interactive mode,
>>
>
> No? Any program may output any of it's values.
>
> so instead ob-python wraps your code in a function,
>> then calls it, and writes the return value of that function to the temp
>> file. Conversely in session mode, each block is talking to the same
>> interactive python interpreter, just what you get if you type 'python' at
>> the shell. So using return() there doesn't make any sense, and wouldn't
>> work.
>>
>
> The use of "return" doesn't depend from interactive mode.
> It's related to a function.
>
> Seen from org-user, IMO any back-ends interactive mode or not is not of
> interest.
> ":session" mimics and/or probably uses it, but it would also possible to
> implement it as a file, loading
> previous values from a storage.
>
> I don't see any way to make them both behave the same way.
>
> Probably most useful at this list is to define which feature/behavior is
> most convenient.
> Why people use this mode, what they want to do.
>
I think the very most useful thing would be for you to code up what you're
thinking of, and show it here.
--
Gary
[-- Attachment #2: Type: text/html, Size: 3655 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2013-03-31 20:04 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28 21:55 run python from org, draft Andreas Röhler
[not found] ` <CAFChFyjZyxcnH1_jSWEUgXNkvJ0c3F8f4ojQa_EtPov2TjtziQ@mail.gmail.com>
2013-03-29 12:11 ` Fwd: " Gary Oberbrunner
2013-03-29 14:47 ` Andreas Röhler
2013-03-29 14:57 ` John Hendy
2013-03-29 15:09 ` Eric Schulte
2013-03-29 15:29 ` Andreas Röhler
2013-03-29 16:20 ` Eric Schulte
2013-03-29 16:49 ` Andreas Röhler
2013-03-29 16:59 ` Eric Schulte
2013-03-29 18:33 ` Evan Misshula
2013-03-29 18:50 ` Eric Schulte
2013-03-29 19:04 ` Evan Misshula
[not found] ` <CAFChFyhRbz6hh-NyOZTfdKJcTPh=F3J=07k2fR9p+A9Wig_pRA@mail.gmail.com>
2013-03-29 20:10 ` Fwd: " Gary Oberbrunner
2013-03-29 20:58 ` Andreas Röhler
2013-03-31 20:04 ` Gary Oberbrunner
2013-03-29 15:35 ` John Hendy
[not found] ` <CAFChFyhOrPVS2E5CE9H2+zX5TFV4D-themQbjx2DaSx-WmG14g@mail.gmail.com>
2013-03-29 20:11 ` Fwd: " Gary Oberbrunner
2013-03-29 15:50 ` John Hendy
2013-03-29 16:23 ` Eric Schulte
2013-03-29 16:47 ` Eric Schulte
2013-03-29 19:06 ` Andreas Röhler
2013-03-29 20:04 ` Andreas Röhler
2013-03-29 19:59 ` Gary Oberbrunner
2013-03-29 20:15 ` Andreas Röhler
2013-03-29 20:25 ` Eric Schulte
2013-03-29 20:45 ` Gary Oberbrunner
2013-03-29 21:13 ` Eric Schulte
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).