Org-mode version 8.0-pre (release_8.0-pre-203-g993e3e @ /home/evan/Documents/org/elisp/org-mode/lisp/)
GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10) of 2013-03-21 on evan-Dell-System-Inspiron-N7110 [2 times]
I installed the patched version. It does hold session definition:
#+name: second-deriv-function
#+begin_src python :session :results output :exports code
def diff2(f, x, h=1E-6):
"""Function that takes the second derivative"""
r=(f(x-h)-2*f(x)+f(x+h))/float(h*h)
return r
#+end_src
#+RESULTS: second-deriv-function
Now let's write a target function, say $g(t)=t^{-6}$:
#+name: target-funtion
#+begin_src python :session :results output :exports code
def g(t):
"""well behaved target function"""
return t**(-6)
#+end_src
#+RESULTS: target-funtion
Now let's define the second derivative and evaluate it at $t=1.2$
#+name: evaluating-the-target
#+begin_src python :session :results output :exports both
t=1.2
d2g = diff2(g,t)
print "g''(%f)=%f" % (t, d2g)
#+end_src
#+RESULTS: evaluating-the-target
:
: >>> g''(1.200000)=9.767798
Works with a named session.