Python 3 and easygui problem
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Sun Feb 22 02:34:02 EST 2009
En Sun, 22 Feb 2009 03:05:51 -0200, Chris Rebert <clp2 at rebertia.com>
escribió:
> 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).
That's very short-lived; cmp is gone in 3.0.1 (should not have existed in
3.0 in the first place).
Try with:
choices.sort(key=str.lower)
--
Gabriel Genellina
More information about the Python-list
mailing list