[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:03:21 CEST 2011


Greg Ewing wrote:
> Nick Coghlan wrote:
>> With this variant, I would suggest that any postdef clause be executed
>> *in addition* to the normal name binding. Colliding on dummy names
>> like "func" would then be like colliding on loop variables like "i" -
>> typically harmless, because you don't use the names outside the
>> constructs that define them anyway.
> 
> That sounds reasonable. However, if we're binding the name
> anyway, why not use it in the main clause instead of introducing
> something weird like a lone 'def'?
> 
>      postdef x = weakref.ref(obj, report_destruction):
>          def report_destruction(obj):
>              print("{} is being destroyed".format(obj))

+1

~Ethan~



More information about the Python-ideas mailing list