[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode][babel]: Some feedback after the first week usage

From: Thomas S. Dye
Subject: Re: [Orgmode][babel]: Some feedback after the first week usage
Date: Fri, 6 Nov 2009 08:56:31 -1000

On Nov 5, 2009, at 7:27 AM, Dan Davison wrote:
Yes, I think we do want a version of this for python and ruby et al. In
your example, the filename is created in python. I suggest doing it
slightly differently, something like this.

#+srcname: fileoutput
#+begin_src python :file outfile.txt
 def savetofile(result, filename):
     with open(filename, 'w') as f:
 savetofile(78, 'outfile.txt')

#+resname: fileoutput

This functionality is now available for ruby & python in branch
ded-babel of git://repo.or.cz/org-mode/babel.git.

So here, if you specify :file <filepath> ruby/python blindly outputs a
link to <filepath>, regardless of the contents of the
code. Responsibility for creating useful contents of <filepath> lies
with the code. Notice that with this you have to specify the output file twice: once as an org-babel directive, and once in the python code. This is in contrast to the graphics languages (dot, ditaa, asymptote), where the results *automatically* get sent to the file specified by :file. The
same is also true now for graphical output from R.

The difference with python, ruby et al is that they might create file
output in a variety of ways which we can't anticipate, so we can't
automatically send output to the file. In contrast, the graphics
language *always* create file output and always do it in the same
way. [And in R it is possible to divert all graphical output to file] A
possible extension of the above might be to use a "magic variable" so
that a python variable is created e.g. __org_babel_output_file__ that
always holds a string corresponding to the file specified by :file. Eric
may have further ideas / views here.

Aloha Dan,

Nice idea.  It is great to have a link to the graphic in the org file.

With the graphics file name available to org-babel, it might be useful to have


or some such thing, return the file name. Then one could do something like this:

#+begin_src latex

This way the file name would only have to be specified twice, and not every time other code wanted to refer to the output of fileoutput.

All the best,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]