Why Python3

Martin v. Loewis martin at v.loewis.de
Tue Jun 29 17:25:49 EDT 2010


Am 29.06.2010 20:30, schrieb Paul Rubin:
> "Martin v. Loewis" <martin at v.loewis.de> writes:
>> And indeed, that's available, by means of the key= argument to list.sort.
> 
> Unfortunately what's needed for more generality is the ability to supply
> a comparison function, which Python2 also offers, but Python3 removes.

That isn't really a problem. You can readily have one:

http://code.activestate.com/recipes/576653-convert-a-cmp-function-to-a-key-function/

> I gave an example a while back of wanting to compare two tree
> structures, and Raymond H. explained how to do it with just a key
> function, which seemed ok at the time.  But thinking about it further
> afterwards, I believe both of us missed then that the method suggested
> doesn't always work, so you really do need cmp.  I'll see if I can find
> the old post and reconstruct the problem.

If you remember, don't forget to post it to the recipe, so that you can
find it more easily the next time.

Regards,
Martin





More information about the Python-list mailing list