emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* noweb and :var statements
@ 2019-10-06 16:33 Ken Mankoff
  2019-10-06 19:39 ` Sebastian Miele
  0 siblings, 1 reply; 10+ messages in thread
From: Ken Mankoff @ 2019-10-06 16:33 UTC (permalink / raw)
  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
<<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'
>>> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-10-07  9:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-06 16:33 noweb and :var statements Ken Mankoff
2019-10-06 19:39 ` 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

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).