emacs-orgmode
[Top][All Lists]
Advanced

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

Re: org-babel guile source block bug in handling multiple values


From: Ihor Radchenko
Subject: Re: org-babel guile source block bug in handling multiple values
Date: Thu, 09 Mar 2023 13:10:56 +0000

Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> writes:

> ~~~~START~~~~
> #+name: python-imports
> #+begin_src python :python /usr/bin/python3 :results output replace drawer 
> :var x=4
> import math
>
> y = math.sqrt(x)
> # print(y)
> #+end_src
>
> #+name: python-usage
> #+begin_src python :python /usr/bin/python3 :return :noweb strip-export 
> :results value replace drawer
> <<python-imports>>
>
> print("y: {}".format(y))
> #+end_src
> ~~~~~END~~~~~
>
> Unfortunately, this example does not seem to work at all, but for a different 
> reason:
>
> It seems that using any Python source block with :var header args via :noweb 
> does not work, as it then behaves in the way, that it merely pasted the 
> included 
> source block, without first putting in the :var values into the variables. I 
> get 
> errors about those :var variables being undefined, of course, since they are 
> on 
> the included source block, not on the including one:
>
> ~~~~START: *Org-Babel Error Output*~~~~
> Traceback (most recent call last):
>    File "<stdin>", line 10, in <module>
>    File "<stdin>", line 5, in main
> NameError: name 'x' is not defined
> [ Babel evaluation exited with code 1 ]
> ~~~~~END~~~~~

This is expected. Noweb includes the src block code without altering it.
See 16.11 Noweb Reference Syntax

We may probably clarify this in the manual. Would it be helpful?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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