Super-rexex?

Fred L. Drake, Jr. fdrake at acm.org
Thu Dec 23 09:50:28 EST 1999


Gerrit Holl writes:
 > I'm looking for a super-rexex. In the current rexec, it's possible
 > to disable all built-in functions and all modules, but I want to
 > disable all statement also, and non-string assignments.
 > 
 > Maybe I have to look for another solution. My problem is:
 > I want to use something like execfile() on a file, but the
 > file should *only* have string definitions!

Gerrit,
  I presume you want the file to have things like this:

FOO = "foo value"
BAR = "bar again?"

  If that's it, there are a couple of ways to do it.  The one that
probably makes the most sense is to change the systax of the file and
use the ConfigParser module to parse an .ini type file:

[MyConfiguration]
FOO=foo value
BAR=bar again?

  Another, more painful approach, but which allows the specific format
you describe, would be to write your own parser for it.  You can use
the tokenize module to help out with tokenization, but it's up to you
to do the actual parse.  Chances are good John Aycock's tools would
really help out.


  -Fred

--
Fred L. Drake, Jr.	  <fdrake at acm.org>
Corporation for National Research Initiatives




More information about the Python-list mailing list