Making Classes Subclassable

dieter dieter at handshake.de
Tue Jul 5 03:55:52 EDT 2016


Lawrence D’Oliveiro <lawrencedo99 at gmail.com> writes:

> 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?

Special proxy objects, i.e. objects that try to behave as much
as possible like another object.

For those objects, you may either want the class of the proxy itself
(--> "type(obj)") or the class of the proxied object (--> "obj.__class__").


Moreover, you might have special descriptors installed which may
affect how "obj.__class__" is resolved.




More information about the Python-list mailing list