emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [BUG][babel] ":result output table" doesn't work for python code


From: Eric Schulte
Subject: Re: [O] [BUG][babel] ":result output table" doesn't work for python code blocks
Date: Thu, 14 Apr 2011 20:26:12 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Ethan Ligon <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]