Sébastien Gendre writes:
> But, 1 + 1 should be 11.
And by 11 you mean 10, of course [1].
> Joke aside, for Python, how you return the value depend of if you use
> a session or not. [...] Is it the article you have read on WORG?
Gotcha.
[1] "There are only 10 types of people in the world: tho
Jack Kamm writes:
>> May we detect if there is a return statement?
>
> That's a nice idea, I like it.
>
> Probably there should be a customization
> `org-babel-python-nonsession-return-style', which could take on the
> values 'require-return (old behavior), 'last-statement (session style),
> or '
Ihor Radchenko writes:
>> I think it would be feasible to switch non-session blocks to use this
>> parser, which IMO is nicer behavior -- the "return" statements always
>> felt weird to me.
>>
>> But a major reason not to do it is to avoid breaking compatibility. Lots
>> of old ob-python nonsessi
Jack Kamm writes:
> Well, ob-python sessions implement this sort of parser in
> `org-babel-python-format-session-value', which AFAIK is robust.
Interesting. I did not remember this.
> I think it would be feasible to switch non-session blocks to use this
> parser, which IMO is nicer behavior --
Ihor Radchenko writes:
> I'm afraid that trying to replicate Python REPL behavior for
> non-interactive src blocks will be beyond what we can reasonably do in
> Org: we would somehow need to detect the last statement in the src
> blocks, which may or may not span a single line; and multiline stat
Jack Kamm writes:
>>> So I think WORG needs to be fixed.
>>>
>>> Can you send a patch?
>>> https://git.sr.ht/~bzg/worg
>>
>> Yes, patch would be welcome.
>
> As Sebastian mentioned, Worg already documents the behavior, under the
> section "Return values":
>
> https://orgmode.org/worg/org-contrib/
Ihor Radchenko writes:
>> In the org-mode documentation I read:
>>
>> For languages like Python, an explicit return statement is mandatory
>> when using ‘:results value’.
>> https://orgmode.org/manual/Results-of-Evaluation.html
>>
>> So I think WORG needs to be fixed.
>>
>> Can you send
"Dr. Arne Babenhauserheide" writes:
>> Today, I decided to start using Python in Org.
>>
>> (1) I read in "WORG":
>>
>> :results {output, value}: [...] Value results are the value of the
>> last expression evaluated in the code block. Value mode is the default
>> (as with other languages).
But, 1 + 1 should be 11.
Joke aside, for Python, how you return the value depend of if you use a
session or not.
By default, a Python code block do not use a session. In this case, when
executed, the code is wrapped into a Python function and then this
function is called. So, to return a value,
Rudolf Adamkovič writes:
> Today, I decided to start using Python in Org.
>
> (1) I read in "WORG":
>
> :results {output, value}: [...] Value results are the value of the
> last expression evaluated in the code block. Value mode is the default
> (as with other languages).
In the org-mode d
Today, I decided to start using Python in Org.
(1) I read in "WORG":
:results {output, value}: [...] Value results are the value of the
last expression evaluated in the code block. Value mode is the default
(as with other languages).
(2) So, I try it, and get:
src_python{1 + 1} {{{resul
11 matches
Mail list logo