Statement local namespaces summary (was Re: python3: 'where' keyword)

Nick Coghlan ncoghlan at iinet.net.au
Tue Jan 11 05:12:34 EST 2005


Nick Coghlan wrote:
> Nick Coghlan wrote:
> 
>> Semantics
>> ---------
>> The code::
>>
>> <statement> with:
>>    <suite>
>>
>> translates to::
>>
>> def unique_name():
>>     <suite>
>>     <statement>
>> unique_name()
>>
> 
> Bleh. Not only was my proposed grammar change wrong, my suggested 
> semantics are wrong, too.
> 
> Raise your hand if you can see the problem with applying the above 
> semantics to the property descriptor example.

Eh, never mind. The following works today, so the semantics I proposed are 
actually fine. (This is exactly the semantics proposed for the property example)

Py> class C(object):
...   def _x():
...     def get(self):
...       print "Hi!"
...     def set(self, value):
...       print "Hi again!"
...     def delete(self):
...       print "Bye"
...     return property(get, set, delete)
...   x = _x()
...
Py> C.x
<property object at 0x009E6738>
Py> C().x
Hi!
Py> C().x = 1
Hi again!
Py> del C().x
Bye

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list