Parsing Python code with a Python Program

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


Hello,

I had my quotes wrong is all.

EXAMPLE:

exec 'print "Hello"'

OR:

s = 'print "hello"'

exec s

Thanks anyway,

Seaweed






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