◐ Shell
clean mode source ↗

Message 67712 - Python tracker

I've attached the latest version of the module as an actual patch
against Python SVN.

It differs slightly from the last version uploaded as separate files, in
that in-place operations on a proxied object will no longer strip the
proxy wrapper off the object. Instead, either the same proxy object will
be returned if the target returned itself from the in-place operation
(mutable objects), or a new proxy wrapper around the result of the
target returned a different object (immutable objects).

Example with a mutable target:
>>> from typetools import ProxyMixin as p
>>> x = p([])
>>> last_x = x
>>> x += [1]
>>> x
<ProxyMixin for [1]>
>>> last_x
<ProxyMixin for [1]>

Example with an immutable target:
>>> from typetools import ProxyMixin as p
>>> x = p(1)
>>> last_x = x
>>> x += 1
>>> x
<ProxyMixin for 2>
>>> last_x
<ProxyMixin for 1>