Exec with loops

Fredrik Lundh effbot at telia.com
Wed Mar 29 01:33:03 CEST 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