I would like to be able to report warnings and errors when evaluating a Python code block in an Org file.
When a code block has Python syntax errors, Org helpfully pops them up in a separate buffer called
*Org-Babel Error Output*. It would be nice to be able to send my own warnings there too, while retaining the ability to return an array result to Org mode as a table using
To be clear, here is a dummy example of the kind of thing I thought might work:
#+BEGIN_SRC python import sys sys.stderr.write('Warning.\n') sys.stderr.flush() return [['Table', 'header'], ['table', 'data']] #+END_SRC #+RESULTS: | Table | header | | table | data |
Edited to add: This discussion on the org-mode list suggests that error output is only displayed when the code-block evaluation fails. So it looks like this is possible, but only by aborting the evaluation using
exit(1) or similar.