Emacs Org Mode: Executing simple python code -
how can execute simple python-code in emacs' org mode?
the first example works fine, can't make give me 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 ; not work #+begin_src python 1+1 #+end_src #+results: : none ; not work #+begin_src python print(1+1) #+end_src #+results: : none
i set org mode using following lines:
;; enable python in-buffer evaluation (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) ;; python code safe (defun my-org-confirm-babel-evaluate (lang body) (not (string= lang "python"))) (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
there two ways of getting result of source block - output
, value
. mixed them up, hence troubles.
first block fine.
to fix second block:
#+begin_src python :results value return 1+1 #+end_src
to fix third block:
#+begin_src python :results output print 1+1 #+end_src
when output mode value
must return
. putting there did 1+1
won't do. in third 1 want result printed output, default session setting value
(mine defaults output
btw).
and bit org-confirm-babel-evaluate
kind of irrelevant question. have set nil
.
Comments
Post a Comment