exec considered harmful
Harald Kirsch
kirschh at lionbioscience.com
Wed Jul 25 03:21:22 EDT 2001
"Nick Perkins" <nperkins7 at home.com> writes:
> why exec(), when you can import?
[snip]
> I have done a fair bit of Python, and *never* used exec() or eval() )
You missed an interesting part and useful application of script
langugages, namely the use of little languages intended for
non-programmers to do some simple tasks. The basic syntax of the
little language is python (in our case), but they are supposed only to
know about a handful of functions you prepared for them. Because you
don't want to require them to write
import TheContrievedLittleLanguageForTheNonProgrammer
in their files, you have to exec() them within a namespace where the
handful of functions you prepared is defined.
Hmm, but maybe there is a way to do that with import?
Harald.
--
----------------+------------------------------------------------------
Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?"
LION bioscience | +49 6221 4038 172 | -- Paul Erdös
*** Please do not send me copies of your posts. ***
More information about the Python-list
mailing list