> Anybody know how to use exec to run code containing arbitrarily > complex loops? Thanks. This'll probably do the trick: >>> s = '''for i in 10 * [None]: print 'Hi there' ''' ... ... >>> >>> t = compile (s, 'string', 'exec') >>> exec (t) Hi there Hi there Hi there Hi there Hi there Hi there Hi there Hi there Hi there Hi there >>> Alex.