From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ahmadou Dicko Subject: Re: Python Code Block error with header option :results output Date: Fri, 31 Jan 2014 21:33:36 +0000 Message-ID: References: <1391187052.2534.12.camel@raven-CM5571> <1391203457.2534.18.camel@raven-CM5571> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e013d0f483b28a704f14aede1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9LiV-0006S8-Q1 for emacs-orgmode@gnu.org; Fri, 31 Jan 2014 16:33:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9LiU-0007QM-Hi for emacs-orgmode@gnu.org; Fri, 31 Jan 2014 16:33:39 -0500 Received: from mail-we0-x22c.google.com ([2a00:1450:400c:c03::22c]:43927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9LiU-0007Q6-Aa for emacs-orgmode@gnu.org; Fri, 31 Jan 2014 16:33:38 -0500 Received: by mail-we0-f172.google.com with SMTP id p61so123121wes.3 for ; Fri, 31 Jan 2014 13:33:36 -0800 (PST) In-Reply-To: <1391203457.2534.18.camel@raven-CM5571> 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: Soapy Smith Cc: emacs-orgmode --089e013d0f483b28a704f14aede1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'm not a Python expert too but I don't that return statement can be used as is on the fly. So, yes is the expected behavior of Python Try instead #+begin_src python :results output a =3D (1, 2, 3, 4) print(a) #+end_src #+RESULTS: : (1, 2, 3, 4) On Fri, Jan 31, 2014 at 9:24 PM, Soapy Smith wrote= : > Hello- > > I am not a user of Python (yet). During a comparison of code block > behavior between Clojure and Python, I discovered a possible Python > error. > > Here is the code block: > > #+begin_src python :results output > a =3D (1, 2, 3, 4) > return a > #+end_src > > The evaluation of this block results in this error: > > File "", line 2 > SyntaxError: 'return' outside function > > Could someone please comment if this is expected Python behavior? > > I am using org 8.2.4. > > Regards, > Greg > > > --=20 Ahmadou H. DICKO statistician economist (Ing=E9nieur Statisticien =C9conomiste) PhD candidate in Climate change economics Faculty of economics and managment - Cheikh Anta Diop University West African Science Service Center on Climate Change and Adaptated Land Use (WASCAL) Center for Development Research (ZEF) - University of Bonn email : ahmadou.dicko@ucad.edu.sn twitter : @dickoah github : github/dickoa tel : +221 33 827 55 16 portable: +221 77 123 81 69 --089e013d0f483b28a704f14aede1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I'm not a Python expert too but I don't that = return statement can be used as is on the fly.
So, yes is the expected b= ehavior of Python

Try instead

#+begin_src python = :results output
=A0 a =3D (1, 2, 3, 4)
=A0 print(a)
#+end_src

#+RESULTS:
: = (1, 2, 3, 4)



On Fri, Jan 31, 2014 at 9:24 PM, Soapy Smith <s= oapy-smith@comcast.net> wrote:
Hello-

I am not a user of Python (yet). =A0During a comparison of code block
behavior between Clojure and Python, I discovered a possible Python
error.

Here is the code block:

#+begin_src python :results output
=A0a =3D (1, 2, 3, 4)
=A0return a
#+end_src

The evaluation of this block results in this error:

=A0 File "<stdin>", line 2
SyntaxError: 'return' outside function

Could someone please comment if this is expected Python behavior?

I am using org 8.2.4.

Regards,
Greg





--
Ahmado= u H. DICKO
statistician economist (Ing=E9nieur Statisticien =C9conomiste= )
PhD candidate in Climate change economics
Faculty of economics and = managment - Cheikh Anta Diop University
West African Science Service Center on Climate Change and Adaptated Land Us= e (WASCAL)
Center for Development Research (ZEF) - University of Bonn email : ah= madou.dicko@ucad.edu.sn
twitter : @dickoah
github : github/dickoa
tel : +221 33 827 55 16
portable: +221 = 77 123 81 69
--089e013d0f483b28a704f14aede1--