Overriding a method at the instance level on a subclass of a builtin type

Arnaud Delobelle arnodel at googlemail.com
Fri Dec 5 16:59:11 EST 2008


Arnaud Delobelle <arnodel at googlemail.com> writes:

[...]

> class ClassGetItem(object):
>     def __get__(self, obj, objtype=None):
>         return obj._getitem_
>     def __set__(self, obj, val):
>         obj._getitem_ = val
>
> class GetItem(object):
>     def __get__(self, obj, objtype=None):
>         return obj._getitem_
>     def __set__(self, obj, val):
>         obj._getitem_ = val

It's funny how the brain works.  I didn't realise both classes were the
same until I read my own post!

[...]

-- 
Arnaud



More information about the Python-list mailing list