emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Ethan Ligon <ligon@are.berkeley.edu>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG][babel] ":result output table" doesn't work for python code blocks
Date: Thu, 14 Apr 2011 20:26:12 -0600	[thread overview]
Message-ID: <87oc485jy3.fsf@gmail.com> (raw)
In-Reply-To: <87k4ew2vfu.fsf@are.berkeley.edu> (Ethan Ligon's message of "Thu, 14 Apr 2011 17:46:13 -0700")

Ethan Ligon <ligon@are.berkeley.edu> writes:

> The results from python code blocks aren't correctly returned as tables
> when they should be.  To wit:
>
> #+begin_src python :results output table
> print "A,B,C"
> #+end_src
>
> #+results:
> : A,B,C
>
> where I'd expect to see
>
> #+results:
> | A | B | C |
>

In many languages ":results output" will always return a scalar, the
thinking being, that what was printed to STDOUT was a series of strings
and thus should be inserted into the buffer as a string, rather than for
example

#+begin_src python
  return [1, 2, 3]
#+end_src

#+results:
| 1 | 2 | 3 |

in which case the value returned is a list, and is thus inserted into
the buffer as a list.

There are currently options for printing to standard out and having the
results inserted as a list.  For example,

#+begin_src python :results output raw
  print "| 1 | 2 | 3 |"
#+end_src

#+results:
| 1 | 2 | 3 |

That said, I agree that in examples like yours above the returned value
should be a table given that the ":results table" is explicitly stated.
I've just pushed up a patch after which the following is possible.

#+begin_src python :results output table
  print "[A, B, C]"
#+end_src

#+results:
| A | B | C |

Note that your exact example above would still not return a list as the
printed value does not look like a python list.

Cheers -- Eric

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

  reply	other threads:[~2011-04-15  2:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15  0:46 [BUG][babel] ":result output table" doesn't work for python code blocks Ethan Ligon
2011-04-15  2:26 ` Eric Schulte [this message]
2011-04-15 10:35   ` Eric S Fraga
2011-04-15 16:13     ` Eric Schulte
2011-04-20 20:28       ` Eric S Fraga
2011-04-26 19:31         ` Eric Schulte
2011-04-27 10:09           ` Eric S Fraga
2011-04-27 13:16             ` Eric Schulte
2011-04-27 15:28               ` Eric S Fraga

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87oc485jy3.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=ligon@are.berkeley.edu \
    /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 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).