Python new-style classes and __subclasses__ function
- by Fraser Graham
Can somebody explain to me why this works (in Python 2.5) :
class Foo(object):
pass
class Bar(Foo):
pass
print(Foo.__subclasses__())
but this doesn't :
class Foo():
pass
class Bar(Foo):
pass
print(Foo.__subclasses__())
The latter returns "AttributeError: class Foo has no attribute '__subclasses__'" but i'm not sure why. I know this is related to old-style vs. new-style classes but i'm not clear on why that would make this functionality unavailable.