Prothon Prototypes vs Python Classes

Michele Simionato michele.simionato at
Sun Mar 28 15:52:10 CEST 2004

Joe Mason <joe at> wrote in message news:<slrnc6cr9n.dit.joe at>...
> Cool.  How come this isn't in either the Language Reference or Library
> Reference?  I just skimmed through those looking for special
> class-related methods the other day, when I first started looking at
> prototypes, and didn't notice __subclasses__, and now I can't find it in
> the index. 

Google this newsgroup for __subclasses__. For some reason the 
developers choose not to document it, but it is there and it seems to be
working. Just as curiosity, __subclasses__ is a meta-method, i.e. it
is a method of the metaclass "type" and not a class method of "object".
For this reason "dir" does not show it

>>> class C(object): pass
>>> dir(C)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash_
_', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr_
_', '__setattr__', '__str__', '__weakref__']

but it is there:

>>> C.__subclasses__()

since it is "acquired" (I don't want to use the word "inherited") from

>>> dir(type)
['__base__', '__bases__', '__basicsize__', '__call__', '__class__', '__cmp__', '
__delattr__', '__dict__', '__dictoffset__', '__doc__', '__flags__', '__getattrib
ute__', '__hash__', '__init__', '__itemsize__', '__module__', '__mro__', '__name
__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str
__', '__subclasses__', '__weakrefoffset__', 'mro']

As you see, mro() is another example of meta-method. I shamelessly remind
for more info.

         Michele Simionato

More information about the Python-list mailing list