Should Python documentation for __class__ be improved?

Olaf Delgado delgado at
Wed Mar 15 09:05:14 CET 2000

In article <MPG.1338953f2ec370a09896ab at>,
	Tom Funk <_spam_sux_tdfunk at> writes:

> So, what __class__ *really* is, is: 
>   o  a reference to where the class itself is imported 
>      into the current name space.  
>   o  that reference is callable and 
>   o  when called it creates a new instance of the class  
>      i.e., 
>          c=Class(arg,...) 
>       is the same as 
>          c=self.__class__(arg,...)

Well, not quite, as Stefan pointed out.

Anyway, I don't see any mistery here. As pointed out by the docs,
classes, like almost anything else, are objects. A class object is
callable, and calling it creates a new instance of that class. Because
classes are just ordinary objects, you can pass them as arguments,
store them in attributes and so on.

> _Python Library Reference_
>    "2.1.8 Special Attributes"
>      __class__ 
>         The class to which a class instance belongs. 

Now 'the class' is not anything like a name or description of a class,
but the class object itself as Python sees it.

I agree that this is pretty cool stuff. But after all, it's just
the way Python is wired, which _is_ pretty cool. :)


  Olaf  Delgado Friedrichs, Bielefeld, Germany
  `='   --- ---

More information about the Python-list mailing list