Self-modifying Code

Dennis Benzinger Dennis.Benzinger at gmx.net
Thu May 19 15:24:36 EDT 2005


qwweeeit at yahoo.it schrieb:
> [...]
> Also Python can (writing and running a module, in-line):
> 
> fNew =open("newModule.py",'w')
> lNew=['print 123\n','print 454\n','print 789\n']
> fNew.writelines(lNew)
> fNew.close()
> from newModule import *
>  [...]

You don't even need a file for this.
Try: exec("print 123; print 456; print 789")

Bye,
Dennis



More information about the Python-list mailing list