Python 3 and easygui problem

Chris Rebert clp2 at rebertia.com
Sun Feb 22 00:05:51 EST 2009


On Sat, Feb 21, 2009 at 8:46 PM, Peter Anderson
<peter.anderson at internode.on.net> wrote:
> I have just installed Python 3. I have been using Tkinter and easygui (with
> Python 2.5.4) for any GUI needs. I have just started to port some of my
> existing scripts to Python 3 and discovered problems with easygui.
>
> I was using the following script for testing:
<snip>

> File "C:\Python30\lib\site-packages\easygui.py", line 824, in __choicebox
> choices.sort( lambda x,y: cmp(x.lower(), y.lower())) # case-insensitive sort
> TypeError: must use keyword argument for key function

Change the line to

choices.sort(key=lambda x,y: cmp(x.lower(), y.lower()))

Note the "key=". The calling sequence for .sort() changed in Python
3.0 to make 'key' a keyword-only argument (I think).

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list