|
From: Aahz <aa...@py...> - 2002-09-14 01:44:12
|
On Fri, Sep 13, 2002, David Goodger wrote: > Aahz wrote: >> >> Well, suppose I've got the following Python code:: >> >> print "Hello, world!" >> >> I'm going to want to include both:: >> >> print "Hello, world!" >> >> and:: >> >> Hello, world! >> >> Thus, there needs to be a directive to *run* the Python code and >> capture stdout (and/or stderr), probably as some kind of literal >> block. > > I see. You want a directive that does the equivalent of > ``os.system()``, and inserts the output into the document. Hmmm. > Seems dangerous to me, to embed system calls in a document. Perhaps > that should be left outside of the document, in the user's production > system (a makefile or a script or whatever)? Or, the directive could > be disabled by default and only enabled with an explicit command-line > option or config file setting. Even then, an interactive prompt may > be useful, such as: > > The file.txt document you are processing contains a "system" > directive requesting that the ``sudo rm -rf /`` command be > executed. Allow it to execute? (y/N) Well, I wasn't expecting this to be a standard directive, I was just explaining the context for wanting the Python code in a separate file. If you want to add this as a standard directive, you've probably got the correct approach. -- Aahz (aa...@py...) <*> http://www.pythoncraft.com/ Project Vote Smart: http://www.vote-smart.org/ |