[Python-Dev] type.subclasses() doesn't work (original) (raw)
Peter Otten __peter__ at web.de
Wed Oct 9 14:22:29 CEST 2013
- Previous message: [Python-Dev] type.__subclasses__() doesn't work
- Next message: [Python-Dev] type.__subclasses__() doesn't work
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Steven D'Aprano wrote:
On Wed, Oct 09, 2013 at 12:20:18PM +0200, Antoine Pitrou wrote:
Hello, Just noticed the following quirk: >>> type.subclasses() Traceback (most recent call last): File "", line 1, in TypeError: descriptor 'subclasses' of 'type' object needs an argument Yet it would be nice to know about the subclasses of type. py> type.subclasses(type) [<class 'abc.ABCMeta'>, <class 'string.TemplateMetaclass'>]
The underlying problem seems to be that there is no helper function to bypass the instance attribute. Compare:
class T(type): ... def len(self): return 0 ... class A(metaclass=T): ... def len(self): return 1 ... A.len() Traceback (most recent call last): File "", line 1, in TypeError: len() missing 1 required positional argument: 'self' len(A) 0
So should there be a subclasses() function, in the operator module perhaps?
- Previous message: [Python-Dev] type.__subclasses__() doesn't work
- Next message: [Python-Dev] type.__subclasses__() doesn't work
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]