Execute a list
Hi. How can i execute a string in python? For example if I have the variable s, defined below s = 'print hello' How can I execute the code that s keeps inside, considering that the code is correct? -- http://mail.python.org/mailman/listinfo/python-list
Re: Execute a list
Here is how to execute code in a string, similar to what was shown in your example: s = 'print hello' exec s hello Hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: Execute a list
Groleo Marius wrote: How can i execute a string in python? How can I execute the code that s keeps inside, considering that the code is correct? Use the exec statement : `exec s` Details at http://www.python.org/doc/ref/exec.html Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list