From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken Mankoff Subject: noweb and :var statements Date: Sun, 06 Oct 2019 18:33:18 +0200 Message-ID: <87k19hg7g1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:59991) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iH9TH-0006OL-Eb for emacs-orgmode@gnu.org; Sun, 06 Oct 2019 12:33:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iH9TG-00016w-An for emacs-orgmode@gnu.org; Sun, 06 Oct 2019 12:33:23 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:33675) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iH9TG-00016F-1I for emacs-orgmode@gnu.org; Sun, 06 Oct 2019 12:33:22 -0400 Received: by mail-lj1-x22c.google.com with SMTP id a22so11184898ljd.0 for ; Sun, 06 Oct 2019 09:33:21 -0700 (PDT) Received: from geus3064linuxwsm (0187900733.0.fullrate.ninja. [2.110.49.174]) by smtp.gmail.com with ESMTPSA id q26sm2218822lfd.53.2019.10.06.09.33.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 06 Oct 2019 09:33:19 -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" To: "emacs-orgmode@gnu.org" Hi Org list, I'm having with noweb and variables. Can someone explain what I'm doing wrong? For example, if I have this table: #+NAME: table_foo | foo | |-----| | 42 | | 100 | And I want to import it into Python and use it, I can do that like this: #+NAME: import #+BEGIN_SRC python :var table=table_foo :session foo import numpy as np table = np.array(table).astype(np.float).flatten() #+END_SRC Eval of this block works, and if I tangle it, I see: > table=[[42], [100]] > import numpy as np > table = np.array(table).astype(np.float).flatten() But if I want to use that block elsewhere via noweb, it doesn't seem to work: #+BEGIN_SRC python :results output drawer :noweb yes :session foo :tangle import_noweb.py <> #+END_SRC The code runs and in a clean *foo* session I do have my table variable, but I *also* get an error. The buffer contains the text at the bottom of this message, and the tangled code in import_noweb.py is only "nil". How can I 1) run noweb blocks with variables and 2) tangle noweb blocks with variables (i.e. tangle tables into source files). Thanks, -k. table=[[42], [100]] Python 2.7.15+ (default, Jul 9 2019, 16:51:35) [GCC 7.4.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> python.el: native completion setup loaded >>> >>> import numpy as np table = np.array(table).astype(np.float).flatten() open('/tmp/babel-Mb4ojd/python-GEnZeZ', 'w').write(str(_)) 'org_babel_python_eoe' >>> Traceback (most recent call last): File "", line 1, in NameError: name '_' is not defined >>> >>> >>> 'org_babel_python_eoe' >>> >>> >>> >>> >>> 'org_babel_python_eoe' 'org_babel_python_eoe' >>>