sort order for strings of digits

Ian Kelly ian.g.kelly at gmail.com
Wed Oct 31 18:24:21 EDT 2012


On Wed, Oct 31, 2012 at 3:33 PM, Mark Lawrence <breamoreboy at yahoo.co.uk>wrote:

> Nope.  I'm busy porting my own code from 2.7 to 3.3 and cmp seems to be
> very dead.
>
> This doesn't help either.
>
> c:\Users\Mark\Cash\Python>**2to3.py
>
> Traceback (most recent call last):
>   File "C:\Python33\Tools\Scripts\**2to3.py", line 3, in <module>
>     from lib2to3.main import main
> ImportError: No module named main
>

Perhaps you have a sys.path conflict?

Use functools.cmp_to_key for porting cmp functions.  "sort(x, my_cmp)"
becomes "sort(x, key=cmp_to_key(my_cmp))"

The cmp builtin is also gone.  If you need it, the suggested replacement
for "cmp(a, b)" is "(b < a) - (a < b)".

Cheers,
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121031/f948bc3d/attachment.html>


More information about the Python-list mailing list