[Tutor] How to use a str object, to find the class in exact name?

Steven D'Aprano steve at pearwood.info
Mon Mar 14 23:23:28 CET 2011


Prasad, Ramit wrote:
> Take a look at: 
> http://stackoverflow.com/questions/701802/how-do-i-execute-a-string-containing-python-code-in-python

And then please don't do it. eval and exec should be treated as the last 
resort, and then only if you really know what you are doing. They are 
slow, and dangerous, especially if there is *any* chance that the input 
strings could be coming from an untrusted user.


-- 
Steven



More information about the Tutor mailing list