__subclasses__ and __sub_classes__

4 views
Skip to first unread message

Mark Lockett

unread,
Nov 17, 2015, 2:38:31 AM11/17/15
to Pyjs.org Users
I am trying to get the subclasses of a class. This is pretty easy in CPython but seems to not work correctly in PYJS

Consider the following classes

class A(object):
    pass

class B(A):
    pass

class C(A):
    pass

In CPython
print str(A.__subclasses__())

Gives

[<class '__main__.B'>, <class '__main__.C'>]

But in PYJS __subclasses__ does not exist. However there is a __sub_classes__ but

print str(A.__sub_classes__)

Unfortunately this retuns

class pyjssubclassesbug.C

In pyjs we get the class of the last subclass defined. This seems to all be in error. The different between __subclasses__ and __sub_classes__ seems to just be a spelling mistake but the rest of the problems just seem like a bug. Is it? Or is this some lind of limitation of javascript or the pyjs compiler?

Otherwise, I am finding this project to be really useful. Many thanks to the authors.

Mark

Reply all
Reply to author
Forward
0 new messages