emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Juan Reyero <joanmg@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Buffer-wide definitions in org-babel
Date: Wed, 07 Oct 2009 12:48:40 -0600	[thread overview]
Message-ID: <m2ocojavlj.fsf@gmail.com> (raw)
In-Reply-To: <55bd243d0910070720i3085af58xc30cf14011d6375a@mail.gmail.com> (Juan Reyero's message of "Wed, 7 Oct 2009 16:20:04 +0200")

Juan Reyero <joanmg@gmail.com> writes:

> Greetings,


> I am trying to define buffer-wide initializations in org-babel, so that I can import a python module once
> and then use its exported symbols in all the code chunks throughout the buffer.  Is there a way to do it?
>  I have tried all the obvious approaches and none seems to work.  (My hope was that I could define a
> :session and then use it in every chunk, but python doesn't like it). 

I believe you are on the right track by trying to use sessions.  The
following works for me

--8<---------------cut here---------------start------------->8---
** persistent python
#+begin_src python :session :results silent
  import types

#+begin_src python :session

: function
--8<---------------cut here---------------end--------------->8---

Of if you grab the latest version of Org-mode from the git repo you can
set the session type in a headline property which would be more similar
to the file-wide behavior that you described.

--8<---------------cut here---------------start------------->8---
*** more persistent python
    :session:  default

#+begin_src python :results silent
  import types

#+begin_src python

: function
--8<---------------cut here---------------end--------------->8---

please let me know if the above don't work for you, or if you are
encountering some other python-babel issues.

> I just found out about org-babel, and I am delighted by its promise.

Thanks! I hope it lives up it's promise.

Best -- Eric

> Org-mode has changed the way I work (after a year and a half I could
> not live without it) but now I think this is going to be another bit
> step. 
> Many thanks,
> jm
> --
> http://juanreyero.com/blog
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2009-10-07 18:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07 14:20 Buffer-wide definitions in org-babel Juan Reyero
2009-10-07 18:48 ` Eric Schulte [this message]
2009-10-07 19:17   ` Eric Schulte
2009-10-08 11:16     ` Juan Reyero
2009-10-08  9:22   ` Juan Reyero
2009-10-08 14:11     ` Dan Davison
2009-10-09 14:53       ` Juan Reyero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2ocojavlj.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=joanmg@gmail.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).