[Python-ideas] Statement local functions and classes (aka PEP 3150 is dead, say 'Hi!' to PEP 403)

Ethan Furman ethan at stoneleaf.us
Fri Oct 14 19:13:07 CEST 2011


Ethan Furman wrote:
> Nick Coghlan wrote:
>> The update to the PEP that I just pushed actually drops class
>> statement support altogether (at least for now), but if it was still
>> there, the above example would instead look more like:
>>
>>     postdef x = property(class.get, class.set, class.delete)
>>     class scope:
>>         def get(self):
>>             return __class__.attr
>>         def set(self, val):
>>             __class__.attr = val
>>         def delete(self):
>>             del __class__.attr
>>
> 
> 
> I like Greg's proposal to use the throw-away name:
> 
>      postdef x = property(scope.get, scope.set, scope.delete)
>      class scope:
>          def get(self):
>              return __class__.attr
>          def set(self, val):
>              __class__.attr = val
>          def delete(self):
>              del __class__.attr

Oh, DRY violation... drat.

~Ethan~



More information about the Python-ideas mailing list