class Proxy: def __init__( self, proxer ): object.__setattr__( self, '_proxer', proxer )
ComplexObject= object viewA= type( 'ComplexView', ( Proxy, ComplexObject ), { '__eq__': lambda self, other: abs( self._proxer- other )<= 1 } ) j= range( 10 ) g= 5 for a in j: p= viewA( a ) print( p.__class__.__name__, p._proxer, p== g ) Subclassing provides an alternative to delegation and proxying. I got this far, but I'm lost: How do I allow g= proxy( 5 ) in line 11? Do I need to? If I do it, I get: TypeError line 7: unsupported operand type(s) for -: 'int' and 'ComplexView' -- http://mail.python.org/mailman/listinfo/python-list