* org-babel-expand-src-block v.s. org-babel-execute-src-block with Python
@ 2017-08-31 23:27 edgar
2017-09-03 12:23 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: edgar @ 2017-08-31 23:27 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
Hello,
I have noticed that doing C-c C-v v (org-babel-expand-src-block) and C-c
C-c (org-babel-execute-src-block) yield different results in Python. I
have attached a file with a MWE and a couple of questions to avoid
clutter in the mailing list. Thank you in advance :) .
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
[-- Attachment #2: t.org --]
[-- Type: text/plain, Size: 1677 bytes --]
I open emacs with ~emacs -Q~
#+BEGIN_SRC emacs-lisp :results none
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(emacs-lisp . t)
(org . t)))
#+END_SRC
* This block works all the time
#+BEGIN_SRC python :python python3 :session
import numpy as np
for i in [1, 2, 3]:
a = i
print(a)
a
#+END_SRC
#+RESULTS:
: 3
* My Python 3 block:
#+BEGIN_SRC python :python python3 :session
import numpy as np
for i in [1, 2, 3]:
# Comment
a = i
print(a)
a
#+END_SRC
#+RESULTS:
* What happens with C-c C-c:
If I do C-c C-c in the block, I get this in the *Python* buffer:
#+BEGIN_EXAMPLE
>>> import numpy as np
>>> for i in [1, 2, 3]:
... # Comment
...
File "<stdin>", line 3
^
IndentationError: expected an indented block
a = i
>>>
File "<stdin>", line 1
a = i
^
IndentationError: unexpected indent
>>> print(a)
>>>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined
>>> open('/tmp/babel-112622VJ/python-112621jw', 'w').write(str(_))
>>>
20
>>>
>>> 'org_babel_python_eoe'
>>> 'org_babel_python_eoe'
>>>
#+END_EXAMPLE
* What happens with C-c C-v v C-c C-c
If I do C-c C-v v C-c C-c in the block, I get this in the *Python* buffer
#+BEGIN_EXAMPLE
>>> 3
>>>
#+END_EXAMPLE
* What happens with C-c ' C-c C-c
If I do C-c ' C-c C-c in the block, I get this in the *Python* buffer
#+BEGIN_EXAMPLE
>>> 3
>>>
#+END_EXAMPLE
* Question:
1. Is this the expected behaviour?
2. Is there a way to get ~#+RESULTS:~ with C-c C-c directly for this kind of blocks?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-03 12:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-31 23:27 org-babel-expand-src-block v.s. org-babel-execute-src-block with Python edgar
2017-09-03 12:23 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.