From mboxrd@z Thu Jan 1 00:00:00 1970 From: Petro Subject: Python execution question Date: Sun, 06 May 2012 13:09:54 +0200 Message-ID: <877gwpd0ql.fsf@cica.cica> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:43127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQzLu-0008EB-JM for emacs-orgmode@gnu.org; Sun, 06 May 2012 07:10:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SQzLs-0007Db-Qe for emacs-orgmode@gnu.org; Sun, 06 May 2012 07:10:10 -0400 Received: from plane.gmane.org ([80.91.229.3]:44041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQzLs-0007Cx-JT for emacs-orgmode@gnu.org; Sun, 06 May 2012 07:10:08 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SQzLn-0004Le-M6 for emacs-orgmode@gnu.org; Sun, 06 May 2012 13:10:03 +0200 Received: from 0x4dd745cf.adsl.cybercity.dk ([77.215.69.207]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 May 2012 13:10:03 +0200 Received: from x.piter by 0x4dd745cf.adsl.cybercity.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 06 May 2012 13:10:03 +0200 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: emacs-orgmode@gnu.org Hi list. I try to process my data in python. I store outputs from different scripts in separate txt files and load data using numpy.loadtxt. I want to change it store outputs in results tables. So I have this example table #+TBLNAME: test-table | 1e212 | 2e1 | 23e3 | and use it as variable for python source code block below #+BEGIN_SRC python :var rates=test-table import numpy as np for i in range(len(rates)): rates[i]=map(float,rates[i]) rates2=np.array(rates) return np.log10(rates2) #+END_SRC #+RESULTS: | 212 | 1.30103 | 4.36172784 | works OK so far. And here comes a problem. I want to be able to debug my code in python session. I use session header argument for it and access session via org-babel-switch-to-session. #+BEGIN_SRC python :var rates=test-table :session import numpy as np for i in range(len(rates)): rates[i]=map(float,rates[i]) rates2=np.array(rates) #+END_SRC #+RESULTS: Then it does not work. And inside of session i have the following output: __________________________________________ >>> rates=[["1e212", "2e1", "23e3"]] >>> import numpy as np for i in range(len(rates)): rates[i]=map(float,rates[i]) rates2=np.array(rates) open('/tmp/babel-54890hk/python-54897vP', 'w').write(str(_)) 'org_babel_python_eoe' >>> ... ... File "", line 3 rates2=np.array(rates) ^ SyntaxError: invalid syntax >>> >>> >>> Traceback (most recent call last): File "", line 1, in NameError: name '_' is not defined >>> >>> >>> 'org_babel_python_eoe' >>> _________________________________________________________ Thank for help in advance. Petro.