all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Passing variables between code blocks
@ 2013-01-24 10:01 Yotam Avital
  2013-01-24 13:38 ` Thomas S. Dye
  0 siblings, 1 reply; 2+ messages in thread
From: Yotam Avital @ 2013-01-24 10:01 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

I want to use org-mode for data analysis for my results. I also want to do
this using small chunks of code blocks for various task. To achieve that. I
need to pass dictionaries (20 entries of lists, each of several hundreds
variables, each is a list by itself). I wanted to do so by the #+CALL
option for example:


* test
  #+NAME:test
  #+BEGIN_SRC python
    vars = dict()
    vars[1] = 1
    vars[2] = 2
    return vars

  #+END_SRC

* caller
  #+NAME: caller
  #+HEADER: :var ins=#+CALL: test()
  #+BEGIN_SRC python :results output
    print files

  #+END_SRC

But I get an error:

  File "<stdin>", line 1
    files=[1:, 1, 2:, 2]
            ^
SyntaxError: invalid syntax

Is there a way to pass a dictionary as a variables between blocks then?



-- 
My other email account has a "professional" signature.

[-- Attachment #2: Type: text/html, Size: 1297 bytes --]

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

* Re: Passing variables between code blocks
  2013-01-24 10:01 Passing variables between code blocks Yotam Avital
@ 2013-01-24 13:38 ` Thomas S. Dye
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas S. Dye @ 2013-01-24 13:38 UTC (permalink / raw)
  To: Yotam Avital; +Cc: emacs-orgmode

Hi Yatam Avital,

Yotam Avital <yotama9@gmail.com> writes:

> I want to use org-mode for data analysis for my results. I also want to do
> this using small chunks of code blocks for various task. To achieve that. I
> need to pass dictionaries (20 entries of lists, each of several hundreds
> variables, each is a list by itself). I wanted to do so by the #+CALL
> option for example:
>
>
> * test
>   #+NAME:test
>   #+BEGIN_SRC python
>     vars = dict()
>     vars[1] = 1
>     vars[2] = 2
>     return vars
>
>   #+END_SRC
>
> * caller
>   #+NAME: caller
>   #+HEADER: :var ins=#+CALL: test()
>   #+BEGIN_SRC python :results output
>     print files
>
>   #+END_SRC

You have the wrong syntax.  There is no need for #+CALL: in this
situation.

See section 14.8.2.1 of the manual:

code block without arguments
a code block name (from the example above), as assigned by #+NAME:, optionally followed by parentheses
          #+BEGIN_SRC emacs-lisp :var length=table-length()
          (* 2 length)
          #+END_SRC

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

end of thread, other threads:[~2013-01-24 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24 10:01 Passing variables between code blocks Yotam Avital
2013-01-24 13:38 ` Thomas S. Dye

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.