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

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Oct 14 09:08:50 CEST 2011


Nick Coghlan wrote:
> On Fri, Oct 14, 2011 at 11:10 AM, Ron Adam <ron3200 at gmail.com> wrote:
> 
>>def sorted_with(key):
>>   def _(seq):
>>       return sorted(seq, key=key)
>>   return _
>>
>>@sorted_with
>>def key_sorted(item):
>>  return item.attr1, item.attr2
>
> Seriously? You're suggesting that mess of symbols and indentation as a
> good answer to the programming task "I want to sort the items in this
> sequence according to the values of attr1 and attr2"?

I don't think that example is as well-constructed as it could be.
The key_sorted function would be better named something like
'sort_by_attr1_and_attr2'.

-- 
Greg




More information about the Python-ideas mailing list