By using :results value
and returning a value, the result will be a list:
#+begin_src python :results value
import os
return os.listdir(path='.')
#+end_src
#+RESULTS:
| python.org | foo.txt | bar.txt |
Returning the results as an org table, as above, makes the results easy to use as the input to other src
blocks. But, if you want the result to be formatted like a python list, you can use :results value pp
:
#+begin_src python :results value pp
import os
return os.listdir(path='.')
#+end_src
#+RESULTS:
: ['python.org', 'foo.txt', 'bar.txt']
or :results output
and print the result:
#+begin_src python :results output
import os
print(os.listdir(path='.'))
#+end_src
#+RESULTS:
: ['python.org', 'foo.txt', 'bar.txt']