Andrew Koenig wrote:
> "Colin J. Williams" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>> 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?
> 
> 
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

Similarly, "with math" creates a newer 
namespace:
   newerGlobal= newGlobal + newLocal
   newerLocal= names from math

My guess is that there would be little 
use for nesting the
"with".

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

Reply via email to