Parsing Python code with a Python Program

pw p.willis at
Mon Aug 23 02:14:34 CEST 2004


I had my quotes wrong is all.


exec 'print "Hello"'


s = 'print "hello"'

exec s

Thanks anyway,


pgw wrote:
> Hello,
> I would like to pass strings to a Python
> application and have them executed as though
> they were lines of code.
> Is 'exec()' the function that I am looking for
> and/or is there an example of this somewhere?
> Thanks,
> Seaweed

More information about the Python-list mailing list