Paul Rubin wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
>> If len() were a method of string objects, you could try using the
>> unbound method and writing this as::
>>
>>      >>> sorted(['aaa', 'bb', 'c'], key=str.len)
>>      ['c', 'bb', 'aaa']
>>
>> But then your code would break on lists that weren't strings.
> 
> sorted(['aaa', 'bb', 'c'], key=lambda x: x.len())

Of course, but all you're doing with the lambda is creating the len() 
function.

STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to