emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] noweb and :var statements


From: Sebastian Miele
Subject: Re: [O] noweb and :var statements
Date: Sun, 06 Oct 2019 21:08:35 +0000
User-agent: mu4e 1.3.5; emacs 26.3

Ken Mankoff <address@hidden> writes:

> On 2019-10-06 at 21:52 +02, Sebastian Miele <address@hidden> wrote...
>> I wrote:
>>
>>> [..]
>>>
>>> However, something like the following may suit your use case. (For the
>>> header-args property see section 15.2 (Using Header Arguments) of the
>>> manual.)
>>>
>>> * A Heading
>>> :PROPERTIES:
>>> :header-args: :var table=table_foo
>>> :END:
>>>
>>> #+NAME: table_foo
>>> | foo |
>>> |-----|
>>> |  42 |
>>> | 100 |
>>>
>>> #+NAME: import
>>> #+BEGIN_SRC python
>>> import numpy as np
>>> table = np.array(table).astype(np.float).flatten()
>>> #+END_SRC
>>>
>>> #+BEGIN_SRC python :noweb yes :tangle import_noweb.py
>>> <<import>>
>>> #+END_SRC
>>
>> Just the following works too, of course:
>>
>> #+NAME: table_foo
>> | foo |
>> |-----|
>> |  42 |
>> | 100 |
>>
>> #+NAME: import
>> #+BEGIN_SRC python
>> import numpy as np
>> table = np.array(table).astype(np.float).flatten()
>> #+END_SRC
>>
>> #+BEGIN_SRC python :noweb yes :var table=table_foo :tangle import_noweb.py
>> <<import>>
>> #+END_SRC
>
> The result of tangling this is "import_noweb.py" contains:
>
> import numpy as np
> table = np.array(table).astype(np.float).flatten()
>
> And I'd like it to somewhere include the line:
> table = [42,100]
> or something similar. I don't have the table data in the tangled code.

Strange. On my system, typing C-c C-v t (org-babel-tangle) in an Org
file with the above mentioned contents does yield a file import_noweb.py
with the following contents:

table=[[42], [100]]
import numpy as np
table = np.array(table).astype(np.float).flatten()

Please try it with emacs -Q. Maybe your config is broken.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]