> I am not advocating this, but this could be:

> def abs(self):
>    with self:
>      with math:
>        return sqrt(x**2 + y**2 + z**2)

> The idea being that "with self" use
> creates a new namespace:
>    newGlobal= oldGlobal + oldLocal
>    newLocal= names from self

You don't know what those names are until runtime.  Suppose, for example,
that self happens to have acquired an attribute named "math"?  Then

        with self:
            with math:
                 return sqrt(x**2 + y**2 + z**2)

doesn't do what you expected, because "with math" turns out to have meant
"with self.math"


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to