On Sat, 2014-02-01 at 07:56 +0100, Christian Moe wrote:
> > You should only use "return" like that in a python code block when you
> > have ":results value".
> 
> To expand briefly on that (since this can be perplexing): 
> 
> The need to use `return' at all when returning the value is a special
> quirk of Python code blocks, and does not apply to (any?) other languages.
> 
> As explained on Worg, with `:results value' (the default), 
> 
> "Internally, the value is obtained by wrapping the code in a function
> definition in the external language, and evaluating that
> function. Therefore, code should be written as if it were the body of
> such a function. In particular, note that Python does not automatically
> return a value from a function unless a return statement is present, and
> so a ‘return’ statement will usually be required in Python."
> 
> http://orgmode.org/manual/Results-of-evaluation.html
> 
> So when using `:results output', using `return' causes an error
> because there is no function to return anything from.
> 
> Yours,
> Christian 

Thank you Christian for the detailed explanation.  It is indeed
perplexing at first!

Regards,
Greg



Reply via email to