Robert Schuppenies <[EMAIL PROTECTED]> added the comment: I tried to implement a magic method __sizeof__() for the type object which should be callable for type objects and type itself. But calling __sizeof__ results in an error message
>>> type.__sizeof__() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: descriptor '__sizeof__' of 'type' object needs an argument Debugging it I found that type_getattro will (1) look for the attribute in the metatype, (2) look in tp_dict of this type, and (3) use the descriptor from the metatype. I actually want it to perform (3), but since type is its own metatype (2) will be triggered. This then results in the need for an argument. The same behavior occurs for all type instances, i.e. classes. Is my understanding correct? How would it be possible to invoke __sizeof__() on the type 'type' and not on the object 'type'? My first approach did the same for object, that is a magic __sizeof__() method linked to object, but it gets ignored when invoked on classes or types. Now from my understanding everything is an object, thus also classes and types. isinstance seems to agree with me >>> >>> isinstance(int, object) True Any suggestions on that? thanks, robert _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2898> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com