the annoying, verbose self

Andrew Koenig ark at
Sun Nov 25 14:47:10 CET 2007

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

> 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