emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* strange behavior with org-babel python
@ 2015-05-12  1:07 Doyley, Marvin M.
  2015-05-12  3:20 ` Puneeth Chaganti
  0 siblings, 1 reply; 4+ messages in thread
From: Doyley, Marvin M. @ 2015-05-12  1:07 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Hi there,

If run the follow codes I get the following, could someone explain to me what is going wrong

(1) The desired results
#+BEGIN_SRC python :results output :exports both :session
x=5
def foo(x):
	if x>0:
		return x+1
	else:
		return x-1

print(foo(x))
#+END_SRC

#+RESULTS:
: 6

(2) No results
#+BEGIN_SRC python :results output raw :exports both 

x=5
if x>0:
	x= x+1
else:
	x= x-1
print(x)
#+END_SRC

#+RESULTS:


(3) Not sure, why I get this error
#+BEGIN_SRC python :results output raw :exports both :session

x=5
if x>0:
	x= x+1
else:
	x= x-1
print(x)
#+END_SRC

#+RESULTS:

>>> >>> >>> >>> ... ...   File "<ipython-input-5-f6e13edbe7ef>", line 3
    else:
         ^
IndentationError: unindent does not match any outer indentation level

If you want to paste code into IPython, try the %paste and %cpaste magic functions.

Thanks,
M

PS in .emacs, I have (setq org-babel-python-command "ipython --no-banner --classic --no-confirm-exit")

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange behavior with org-babel python
  2015-05-12  1:07 strange behavior with org-babel python Doyley, Marvin M.
@ 2015-05-12  3:20 ` Puneeth Chaganti
  2015-05-12  9:10   ` Doyley, Marvin M.
  0 siblings, 1 reply; 4+ messages in thread
From: Puneeth Chaganti @ 2015-05-12  3:20 UTC (permalink / raw)
  To: Doyley, Marvin M.; +Cc: emacs-orgmode@gnu.org

On Tue, May 12, 2015 at 6:37 AM, Doyley, Marvin M.
<mdoyley@ur.rochester.edu> wrote:
> Hi there,
>
> If run the follow codes I get the following, could someone explain to me what is going wrong
[snip]
> PS in .emacs, I have (setq org-babel-python-command "ipython --no-banner --classic --no-confirm-exit")

To reliably paste code blocks into IPython, you will have to use
%cpaste magic command.  See any of these links[1][2][3] for code you
can reuse.

[1] - https://github.com/punchagan/dot-emacs/blob/master/punchagan.org#python-customizations
[2] - https://lists.gnu.org/archive/html/emacs-orgmode/2014-03/msg00405.html
[3] - http://emacs.stackexchange.com/questions/3859/working-setup-for-ipython-in-babel

Hope that helps,
Puneeth

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange behavior with org-babel python
  2015-05-12  3:20 ` Puneeth Chaganti
@ 2015-05-12  9:10   ` Doyley, Marvin M.
  2015-05-13 17:49     ` Puneeth Chaganti
  0 siblings, 1 reply; 4+ messages in thread
From: Doyley, Marvin M. @ 2015-05-12  9:10 UTC (permalink / raw)
  To: Puneeth Chaganti; +Cc: emacs-orgmode@gnu.org

Thanks, this works when I use :session,
but I don’t get any results when I am not running a session. 
Doy you know why this is the case?

Cheers,
M
On May 11, 2015, at 11:20 PM, Puneeth Chaganti <punchagan@gmail.com> wrote:

> On Tue, May 12, 2015 at 6:37 AM, Doyley, Marvin M.
> <mdoyley@ur.rochester.edu> wrote:
>> Hi there,
>> 
>> If run the follow codes I get the following, could someone explain to me what is going wrong
> [snip]
>> PS in .emacs, I have (setq org-babel-python-command "ipython --no-banner --classic --no-confirm-exit")
> 
> To reliably paste code blocks into IPython, you will have to use
> %cpaste magic command.  See any of these links[1][2][3] for code you
> can reuse.
> 
> [1] - https://github.com/punchagan/dot-emacs/blob/master/punchagan.org#python-customizations
> [2] - https://lists.gnu.org/archive/html/emacs-orgmode/2014-03/msg00405.html
> [3] - http://emacs.stackexchange.com/questions/3859/working-setup-for-ipython-in-babel
> 
> Hope that helps,
> Puneeth

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange behavior with org-babel python
  2015-05-12  9:10   ` Doyley, Marvin M.
@ 2015-05-13 17:49     ` Puneeth Chaganti
  0 siblings, 0 replies; 4+ messages in thread
From: Puneeth Chaganti @ 2015-05-13 17:49 UTC (permalink / raw)
  To: Doyley, Marvin M.; +Cc: emacs-orgmode@gnu.org

On Tue, May 12, 2015 at 2:40 PM, Doyley, Marvin M.
<mdoyley@ur.rochester.edu> wrote:
> Doy you know why this is the case?

I'm not sure what is going on here, and have not been able to
reproduce your problem.  What version of Emacs and Org-mode are you
using?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-13 17:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-12  1:07 strange behavior with org-babel python Doyley, Marvin M.
2015-05-12  3:20 ` Puneeth Chaganti
2015-05-12  9:10   ` Doyley, Marvin M.
2015-05-13 17:49     ` Puneeth Chaganti

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).