[Python-Dev] PEP 309: Partial method application

Raymond Hettinger raymond.hettinger at verizon.net
Thu Aug 18 18:43:07 CEST 2005


> > [Ian Bicking]
> > > I think partial() misses an important use case of method getting,
for
> > > instance:
> > >
> > >      lst = ['A', 'b', 'C']
> > >      lst.sort(key=partialmethod('lower'))
> >
> > We've already got one:
> >
> >        lst.sort(key=operator.attrgetter('lower'))
> 
> Doesn't that just sort on the str.lower or unicode.lower method
object?

My mistake.  It sorts on the bound method rather than the results of
applying that method.


Raymond



More information about the Python-Dev mailing list