On Jun 24, 6:28 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Sun, 24 Jun 2007 11:17:40 +1000, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> >On Sat, 23 Jun 2007 19:58:32 +0000, vasudevram wrote:
>
> >> Hi group,
>
> >> Question: Do eval() and exec not accept a function definition? (like
> >> 'def foo: pass) ?
>
> >eval() is a function, and it only evaluates EXPRESSIONS, not code blocks.
>
> Actually, that's not exactly true:
>
>     >>> x = compile('def foo():\n\tprint "hi"\n', '<stdin>', 'exec')
>     >>> l = {}
>     >>> eval(x, l)
>     >>> l['foo']()
>     hi
>     >>>
>
> Jean-Paul

Thanks, all. Will check out the replies given.
- Vasudev

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to