how to dynamically instantiate an object inheriting from several classes?

Joe Strout joe at strout.net
Sat Nov 22 15:32:07 CET 2008


On Nov 21, 2008, at 7:02 PM, Steven D'Aprano wrote:

>> I have a function that takes a reference to a class,
>
> Hmmm... how do you do that from Python code? The simplest way I can  
> think
> of is to extract the name of the class, and then pass the name as a
> reference to the class, and hope it hasn't been renamed in the  
> meantime...

Please quit trying to confuse the kids at home.  Classes in Python are  
first-class objects, and any time you refer to a class or any other  
object in Python, what you have is a reference to it.

    <http://www.strout.net/info/coding/valref/>

Cheers,
- Joe




More information about the Python-list mailing list