I've got some Python source code blocks in my Org mode document and when I print lists as output I get an org table of one row with all elements (regardless of whether I create a session or not):

#+BEGIN_SRC python :session
list = [1, 2, 3, 4]

| 1 | 2 | 3 | 4 |

For long lists this is inconvenient (also when exporting to LaTeX/PDF, for example). Is there a way to change the output to one column, multiple rows?

I have tried adding :results list to the source block header, which sort of gives me what I want. Nevertheless, a table is preferred over a list.

1 Answer 1


You can output a column vector by mapping each list element to a row element of a new list of lists (matrix):

#+BEGIN_SRC python :session
mylist = [1, 2, 3, 4, 5, 6]
map( lambda x: [x], mylist )

| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
  • Interestingly, when trying your solution in Python3 it didn't work (the output was <map object at 0x7fe3b0a36160>). So I decided to convert your solution to a list comprehension: [ [x] for x in mylist ]. This works also in Python3
    – ph0t0nix
    Commented Nov 11, 2016 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.