Hello, I solved this with (org-sbe). For example, using "add-one" and "table" from the original email
#+Name: test-add-one #+BEGIN_SRC python :results output values :var data=(org-sbe add-one (data table)) print(data) #+END_SRC #+RESULTS: test-add-one : 43 Or src_elisp{(org-sbe add-one (data table))} {{{results(=43=)}}} -k. On 2019-09-16 at 10:21 -07, Ken Mankoff <mank...@gmail.com> wrote... > I'd like to modify a variable with a babel block before another block > sees the variable. For example, I always want to add one to a > variable: > > #+NAME: add-one > #+BEGIN_SRC bash :results verbatim :var data=0 > data=$(( data + 1 )) > echo $data > #+END_SRC > > #+RESULTS: add_one > : 1 > > Test it: > > #+CALL: add_one(data=42) > > #+RESULTS: > : 43 > > Can I use =add_one= to modify data passed elsewhere? > > For example, given > > #+NAME: table > | 42 | > > I'm having trouble defining a =print_table= function that prints 43, using > the =add_one= either via :prologue or <<noweb>> or some other method. > Preferably prologue because then the add_one function could be in a different > language. > > > I can get halfway to what I want with a :post option, but need this to be a > :pre or :prologue. Example using :post > > #+NAME: python_using_add_one > #+BEGIN_SRC python :results output values :post add-one(data=*this*) > print(42) > #+END_SRC > > #+RESULTS: python_using_add_one > : 43 > > Any suggestions how to use this feature with :pre or :prologue? > > Thanks, > > -k