Recursion in compile()

Narendra C. Tulpule naren at trillium.com
Thu Jul 17 02:29:08 CEST 2003


Hi,
  is there any way to allow recusrion in compile()? Something like:

src_code = 'def fact(n):\n\tif n <= 1:\n\t\treturn 1\n\telse:' + \
           '\n\t\treturn n * fact(n-1)\n\nprint fact(12)\n'
cobj = compile(src_code, 'myfile', 'exec')
eval(cobj)

I did a search on 'recursion' in comp.lang.python but didn't turn up
anything relevant. Maybe I've highhhhhh expectations :-)
-- Naren.




More information about the Python-list mailing list