Ethan Ligon <li...@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 via email to