Context manager with class methods
Gregory Ewing
greg.ewing at canterbury.ac.nz
Fri Sep 23 20:07:54 EDT 2011
More information about the Python-list mailing list
Fri Sep 23 20:07:54 EDT 2011
- Previous message (by thread): Context manager with class methods
- Next message (by thread): Execute code after Shut Down command given --- How?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Terry Reedy wrote: > it is normal to look for special methods on the class (and superclasses) > of an object rather than starting with the object itself. > I suspect there was a deliberate change to correct an anomaly, though > this might have been done as part of some other change. It's a necessary consequence of the fact that new-style classes are also instances. Without it, there would be an ambiguity as to whether a special method defined the behaviour of instances of a class or of the class object itself. It also increases efficiency, because for those special methods that correspond to C-level type slots, you only have to look in the type slot to find an implementation of the method, rather than having to look in the instance dict first. -- Greg
- Previous message (by thread): Context manager with class methods
- Next message (by thread): Execute code after Shut Down command given --- How?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list