Poll on Eval in Python

Nobody nobody at nowhere.com
Wed Oct 21 06:03:35 CEST 2009

On Tue, 20 Oct 2009 11:08:00 -0700, TerryP wrote:

> On Oct 20, 4:30 pm, Nobody <nob... at nowhere.com> wrote:
>> One language's "eval" isn't the same as another's. E.g. there's a big
>> difference between Lisp's "eval" (which takes an s-expression as an
>> argument) and an "eval" which takes a string as an argument.
>> The former is fine; the latter should be prohibited by law, and preferably
>> by international treaty.
> The ability to eval a string can be useful in generating code from a
> template at run time, among other things.

Only if that's the only eval that's available. If you have the option of
read-modify-eval (i.e. separate read and eval operations), that's almost
invariably preferable to the modify(string)-read-eval approach which
you're forced to use if parsing and evaluation are joined at the hip.
Although I'm not sure about the "almost".

More information about the Python-list mailing list