By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,533 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,533 IT Pros & Developers. It's quick & easy.

Prothon Prototypes vs Python Classes

P: n/a
Joe Mason <jo*@notcharles.ca> wrote in message news:<sl****************@gate.notcharles.ca>...
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
"type":
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
to http://www-106.ibm.com/developerwork...ary/l-pymeta2/
for more info.

Michele Simionato
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.