How to execute lists of code? Or alternatives.

Alex cut_me_out at hotmail.com
Tue May 9 15:16:47 EDT 2000


> If there is a way to exec multiple statements (including conditionals,
> loops, etc.), that would be fine.

You're in luck.  

>>> s = '''print 'hi'
... print 'there'
... '''
>>> c = compile (s, 'string', 'exec')
>>> exec (c)
hi
there
>>> 

Alex.



More information about the Python-list mailing list