how to dynamically instantiate an object inheriting from several classes?

Arnaud Delobelle arnodel at googlemail.com
Sat Nov 22 11:20:32 EST 2008


Joe Strout <joe at strout.net> writes:

> 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/>

Why don't you put this link in your sig?  It'll save you time.  If I
were you though I would wait a bit until I have had more experience with
Python (In case you change your mind).

In the meantime why not adopt the terminology commonly used on this list
and by Python users at large?  Nobody else would talk about 'a function
that takes a reference to a class'.  It's just plain confusing.

-- 
Arnaud



More information about the Python-list mailing list