From: Ken Mankoff <mankoff@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: noweb and :var statements
Date: Sun, 06 Oct 2019 18:33:18 +0200 [thread overview]
Message-ID: <87k19hg7g1.fsf@gmail.com> (raw)
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
<<import()>>
#+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 "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> >>> >>> 'org_babel_python_eoe'
>>>
>>>
>>>
>>>
>>> 'org_babel_python_eoe'
'org_babel_python_eoe'
>>>
next reply other threads:[~2019-10-06 16:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-06 16:33 Ken Mankoff [this message]
2019-10-06 19:39 ` noweb and :var statements Sebastian Miele
2019-10-06 19:52 ` Sebastian Miele
2019-10-06 20:08 ` Ken Mankoff
2019-10-06 21:08 ` Sebastian Miele
2019-10-06 21:17 ` Sebastian Miele
2019-10-07 5:18 ` Ken Mankoff
2019-10-07 9:22 ` Sebastian Miele
2019-10-06 20:05 ` Ken Mankoff
2019-10-06 20:55 ` Sebastian Miele
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k19hg7g1.fsf@gmail.com \
--to=mankoff@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).