sorting list of complex numbers

Hrvoje Niksic hniksic at xemacs.org
Wed Nov 19 18:10:47 CET 2008


Terry Reedy <tjreedy at udel.edu> writes:

> Hrvoje Niksic wrote:
>> Terry Reedy <tjreedy at udel.edu> writes:
>>
>>> Do your tuple destructuring in the first statement in your body and
>>> nothing will break.
>>
>> Unless you were using a lambda, which is quite useful as argument to
>> "sort".
>
> So write a separate def statement.

That is a valid possibility, but loses the succinctness of a short
lambda.  Some uses of lambda+unpacking can also be replaced by
operator.itemgetter.

> If you do not want to do that, don't run with 3.0.

Tuple unpacking in parameters is a useful feature, but hardly reason
enough to abandon the future of the language.



More information about the Python-list mailing list