the annoying, verbose self

Andrew Koenig ark at acm.org
Sun Nov 25 08:47:10 EST 2007


"Colin J. Williams" <cjw at sympatico.ca> wrote in message 
news:mailman.1557.1195995738.13605.python-list at python.org...

> Alternatively, as someone else suggested, an analogue of the Pascal "with"
> could be used:
>
> def abs(self):
>   with self:
>     return math.sqrt(x**2 + y**2 + z**2)

How does your suggested "with" statement know to transform x into self.x but 
not transform math.sqrt into self.math.sqrt?





More information about the Python-list mailing list