Making Classes Subclassable
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Jul 5 04:31:58 EDT 2016
On Monday 04 July 2016 18:34, Lawrence D’Oliveiro wrote:
> On Monday, July 4, 2016 at 7:58:07 PM UTC+12, dieter wrote:
>> --> "type(obj)" or "obj.__class__" (there are small differences)
>> give you the type/class of "obj".
>
> When would it not be the same?
class X(object):
def __getattribute__(self, name):
if __name__ == '__class__':
return int
return super().__getattribute__(name)
--
Steve
More information about the Python-list
mailing list