define a new func on the fly?

Costas Menico costas at meezon.com
Thu Mar 1 21:56:45 EST 2001


Gregory Jorgensen<gregj at pobox.com> wrote:

>eval() evaluates an expression. exec() executes a statement. Try this:
>
>>>> exec("def f():\n\treturn 'hello'\t")

When I try the above I get a syntax error... I am using PythonWin. Is
this a bug?

Costas


>>>> f()
>'hello'
>
>>>> eval("f()")
>'hello'




More information about the Python-list mailing list