From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Fwd: run python from org, draft Date: Fri, 29 Mar 2013 10:20:06 -0600 Message-ID: <87ehey6upd.fsf@gmail.com> References: <5154BC51.1050001@easy-emacs.de> <5155A97D.2090907@easy-emacs.de> <87sj3e6y5n.fsf@gmail.com> <5155B346.3060708@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:49899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULc61-0003ta-1E for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 12:24:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULc5w-00048f-FV for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 12:24:04 -0400 Received: from mail-da0-x235.google.com ([2607:f8b0:400e:c00::235]:33612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULc5w-00048Q-9i for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 12:24:00 -0400 Received: by mail-da0-f53.google.com with SMTP id n34so268287dal.40 for ; Fri, 29 Mar 2013 09:23:59 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andreas =?utf-8?Q?R=C3=B6hler?= Cc: emacs-orgmode , Gary Oberbrunner Andreas R=C3=B6hler writes: > Am 29.03.2013 16:09, schrieb Eric Schulte: >>>> with current >>>> >>>> GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.14) of 2013-03-= 05 >>>> >>>> Org-mode version 7.9.3f (release_7.9.3f-17-g7524ef @ >>>> MY_PATH/emacs-24.3/lisp/org/) >>>> >>>> python from org-source seems completely broken. >>>> >>>> For example: >>>> >>>> #+BEGIN_SRC python >>>> 1+2 >>>> #+END_SRC >>>> >>>> #+RESULTS: >>>> : None >>>> >>>> >>> Weird. With all the testing we did last week, I'm surprised that this is >>> the case with me as well. I'm also getting no results with Org 8.0-pre = and >>> Emacs 24.3.1. >>> >> >> Because of quirks of the python language, > > or rather the quirks of org-babel? ;) > > when executing outside of a >> session, it is necessary to explicitly specify a return. >> >> For example. >> >> #+begin_src python >> return 1+2 >> #+end_src >> >> #+RESULTS: >> : 3 >> >> or >> >> #+begin_src python :return x >> x =3D 1+2 >> #+end_src >> >> #+RESULTS: >> : 3 >> >> This is clearly stated in the Python documentation on Worg. >> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html >> >> Thanks, >> > > IMO org-babel should be able to run source code as is. A valid opinion, in fact I think I defended that point of view myself, and we used to wrap python code in a function so that we could easily return the result of the block without an explicit return statement. However people who use Python more than myself argued for the current behavior and made a convincing point. Please look back through the mailing list archives to see the discussion if you're not convinced. >=20 > If an org-mode specific modification is required at such a trivial > form, what to expect wrt complex environments? > People have been using Org-mode's code block support for years, often in complex environments. However they tend to get along better if they read the documentation. > > BTW this fails also: > > #+begin_src python > print "Hello, world!" > #+end_src python > > #+RESULTS: > : None > Because it does not return any value, and you are asking for the value, if you add ":results output" to the header of that code block you'll get what you appear to expect. I acknowledge that there are a host of header arguments and things to learn (value vs. output, language specific quirks etc...) to enable sophisticated use of code blocks in Org-mode. The best way to learn this stuff is through the documentation, *not* through repeatedly sending non working examples to the mailing list. > > > Can't see a consistent behavior so far. > > Why not follow the path given, which avoids the artistics? > I don't understand this last sentences at all. > > > Andreas > > > --=20 Eric Schulte http://cs.unm.edu/~eschulte