Recursion in compile()
Steven Taschuk
staschuk at telusplanet.net
Wed Jul 16 22:13:24 EDT 2003
Quoth Narendra C. Tulpule:
> 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)
This works fine for me -- it prints 479001600 as expected, on both
2.2.2 and 2.3b1. What is the problem you're seeing?
--
Steven Taschuk staschuk at telusplanet.net
"I tried to be pleasant and accommodating, but my head
began to hurt from his banality." -- _Seven_ (1996)
More information about the Python-list
mailing list