define a new func on the fly?

Gregory Jorgensen gregj at pobox.com
Fri Mar 2 02:00:44 EST 2001


It should be a \n after 'hello', not \t. Sorry for the typo.


In article <3a9f0bc2.10059041 at News.CIS.DFN.DE>, Costas Menico says...
>
>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'
>

Greg Jorgensen
Deschooling Society
Portland, Oregon, USA
gregj at pobox.com



More information about the Python-list mailing list