I would like to use some python code with babel to output some computation result about the current org file. As I'll be doing this quite often, I'd like ideally to have access to it's file name without hard-writing it's name in my code.
For instance:
#+begin_src python :results output :exports results
with open("myself.org") as f:
contents = f.read()
print "Current org file line count: %d" % len(contents.split("\n"))
#+end_src
I would want to get rid of the hard-writen "myself.org"
, which is supposed to point towards the current file name.
Is there any macro possibility in source code block that would insert the current org file's name in the some placeholder in this code block before evaluation ?
Or is there any way to add variables in python code scope to all code blocks which would then allow access to the current file path at run time through variables or any other means ?