Exec with loops

Fredrik Lundh effbot at telia.com
Tue Mar 28 18:33:03 EST 2000


scottusenet at ithink.org wrote:
> Is it possible to use exec to run code that includes a loop? For example:
> a='for b in range(4):\n print b' exec a This fails with a syntax error.

add a newline to the end of the string, and it'll work.

</F>





More information about the Python-list mailing list