Emacs Org Mode: Executing simple python code
How can I execute very simple Python-Code in Emacs' Org Mode?
The first example works fine, however I can't make it give me the result
of simplest computations:
; works
#+begin_src python
def foo(x):
if x>0:
return x+10
else:
return x-1
return foo(50)
#+end_src
#+RESULTS:
: 60
; does not work
#+begin_src python
1+1
#+end_src
#+RESULTS:
: None
; does not work
#+begin_src python
print(1+1)
#+end_src
#+RESULTS:
: None
I set up Org Mode using the following lines:
;; enable python for in-buffer evaluation
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)))
;; let's define all python code as safe
(defun my-org-confirm-babel-evaluate (lang body)
(not (string= lang "python")))
(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
No comments:
Post a Comment