all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Soapy Smith <soapy-smith@comcast.net>
To: Christian Moe <mail@christianmoe.com>
Cc: emacs-orgmode@gnu.org, Eric Schulte <schulte.eric@gmail.com>
Subject: Re: Python Code Block error with header option :results output
Date: Sat, 01 Feb 2014 07:34:57 -0500	[thread overview]
Message-ID: <1391258097.11022.7.camel@raven-CM5571> (raw)
In-Reply-To: <m2ioszl3su.fsf@uio.no>

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	other threads:[~2014-02-01 12:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 16:50 Export Dispatcher Insert Template Not Working? Soapy Smith
2014-01-31 17:04 ` Bastien
2014-01-31 21:05   ` Soapy Smith
2014-01-31 21:24 ` Python Code Block error with header option :results output Soapy Smith
2014-01-31 21:33   ` Ahmadou Dicko
2014-01-31 21:33   ` Eric Schulte
2014-02-01  6:56     ` Christian Moe
2014-02-01 12:34       ` Soapy Smith [this message]
2014-01-31 21:45 ` Code block option :results raw does not replace #+RESULTS Soapy Smith
2014-01-31 21:54   ` John Hendy
2014-01-31 23:16   ` Nick Dokos
2014-02-01 12:01     ` Soapy Smith

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391258097.11022.7.camel@raven-CM5571 \
    --to=soapy-smith@comcast.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@christianmoe.com \
    --cc=schulte.eric@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.