Recursion in compile()

Steven Taschuk staschuk at telusplanet.net
Thu Jul 17 20:04:13 EDT 2003


Quoth Narendra C. Tulpule:
  [...]
> I was trying something like 
> cobj = compile('eval(src_code)', ...)
> eval(cobj)
> And that complains about syntax error (because I am trying to define a
> function within eval string?)

That would do it -- with a string argument, eval only does
expressions, not statements (and so in particular, not def
statements).

Try
    compile('exec src_code')
instead.

-- 
Steven Taschuk                            staschuk at telusplanet.net
Every public frenzy produces legislation purporting to address it.
                                                  (Kinsley's Law)





More information about the Python-list mailing list