Try this
The reason why the error happens is because you haven't defined y
in the x=y
arguments.
If you update code as follows noweb
will work
#+NAME: cubed-plus-cubed
#+BEGIN_SRC python :noweb eval
return <<cubed(x=3)>> + <<cubed(x=3)>>
#+END_SRC
#+RESULTS: cubed-plus-cubed
: 54
However I suspect this is not what you wanted because originally you added :var y=0
Another way to pass the value of variable x
is to update your code as follows:
example 1
#+NAME: cubed-ex1
#+BEGIN_SRC python :var x=3 :session
x * x * x
#+END_SRC
#+RESULTS: cubed-ex1
: 27
#+NAME: cubed-plus-cubed-ex1
#+BEGIN_SRC python :var x=3 :noweb eval :session
<<cubed-ex1>> + <<cubed-ex1>>
#+END_SRC
#+RESULTS: cubed-plus-cubed-ex1
: 54
example 2
Add named example with value, e.g. x-ex2
#+NAME: x-ex2
: 3
Pass named value to noweb
#+NAME: cubed-plus-cubed-ex2
#+BEGIN_SRC python :noweb eval
return <<cubed(x=x-ex2())>> + <<cubed(x=x-ex2())>>
#+END_SRC
#+RESULTS: cubed-plus-cubed-ex2
: 54
Hope that helped!
This code was tested using
emacs version: GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10)
org-mode version: Org mode version 9.1.2