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!  
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?

Reply via email to