Using Variables for Class Names in Python?

Posted by Sam McAfee on Stack Overflow See other posts from Stack Overflow or by Sam McAfee
Published on 2008-10-21T21:24:24Z Indexed on 2010/05/20 15:20 UTC
Read the original article Hit count: 192

Filed under:
|

I want to know how to use variables for objects and function names in Python. In PHP, you can do this:

$className = "MyClass";

$newObject = new $className();

How do you do this sort of thing in Python? Or, am I totally not appreciating some fundamental difference with Python, and if so, what is it?

© Stack Overflow or respective owner

Related posts about python

Related posts about dynamic-typing