diff options
authorEric Schulte <>2012-10-31 00:04:41 (GMT)
committer Eric Schulte <>2012-10-31 00:04:50 (GMT)
commit32a6bae7c0ff83ec0f30e7c89886701dfa3f015b (patch)
parent14e0cd553f43f253b7dcf689826cc95ef84895e9 (diff)
better hline and None translations in ob-python
* lisp/ob-python.el (org-babel-python-hline-to): Customize hline conversion to python. (org-babel-python-None-to): Customize none conversion from python. (org-babel-python-var-to-python): Use new variable. (org-babel-python-table-or-string): Use new variable.
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 71adf73..041f4b5 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -52,6 +52,12 @@ This will typically be either 'python or 'python-mode.")
(defvar org-src-preserve-indentation)
+(defcustom org-babel-python-hline-to "None"
+ "Replace hlines in incoming tables with this when translating to python.")
+(defcustom org-babel-python-None-to 'hline
+ "Replace 'None' in python tables with this before returning.")
(defun org-babel-execute:python (body params)
"Execute a block of Python code with Babel.
This function is called by `org-babel-execute-src-block'."
@@ -114,7 +120,7 @@ specifying a variable of the same value."
(if (listp var)
(concat "[" (mapconcat #'org-babel-python-var-to-python var ", ") "]")
(if (equal var 'hline)
- "None"
+ org-babel-python-hline-to
(if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
@@ -123,7 +129,13 @@ specifying a variable of the same value."
"Convert RESULTS into an appropriate elisp value.
If the results look like a list or tuple, then convert them into an
Emacs-lisp table, otherwise return the results as a string."
- (org-babel-script-escape results))
+ ((lambda (res)
+ (if (listp res)
+ (mapcar (lambda (el) (if (equal el 'None)
+ org-babel-python-None-to el))
+ res)
+ res))
+ (org-babel-script-escape results)))
(defvar org-babel-python-buffers '((:default . nil)))