Re: Unicode and dictionaries

2010-01-17 Thread Ben Finney
gizli writes: > >>> test_dict = {u'öğe':1} > >>> u'öğe' in test_dict.keys() > True > >>> 'öğe' in test_dict.keys() > True I would call this a bug. The two objects are different, so the latter expression should return ‘False’. FYI, ‘foo in bar.keys()’ is easier to spell as ‘foo in bar’. -- \

Re: Unicode and dictionaries

2010-01-17 Thread Martin v. Loewis
>>> This ought to be a bug; objects that compare equal and are hashable >>> must have the same hash code. >> It's not a bug. Changing the default encoding is not really supported, >> let alone changing it to anything but latin-1, precisely for the reasons >> you discuss. >> >> If you do change the

Re: Unicode and dictionaries

2010-01-17 Thread Steven D'Aprano
On Sun, 17 Jan 2010 10:49:44 +0100, Martin v. Loewis wrote: >> This ought to be a bug; objects that compare equal and are hashable >> must have the same hash code. > > It's not a bug. Changing the default encoding is not really supported, > let alone changing it to anything but latin-1, precisely

Re: Unicode and dictionaries

2010-01-17 Thread Martin v. Loewis
> Thanks to all of you. This once again proves how deep you can get > yourself into a mess if you mix unicode and string objects in your > code! The specific issue is that you apparently changed the default encoding. Don't do that, Python will break if you do. Regards, Martin -- http://mail.pyth

Re: Unicode and dictionaries

2010-01-17 Thread Martin v. Loewis
> This ought to be a bug; objects that compare equal and are hashable > must have the same hash code. It's not a bug. Changing the default encoding is not really supported, let alone changing it to anything but latin-1, precisely for the reasons you discuss. If you do change the default encoding,

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
On Jan 16, 7:06 pm, Ben Finney wrote: > Carl Banks writes: > > On Jan 16, 3:56 pm, Ben Finney wrote: > > > gizli writes: > > > > >>> test_dict = {u'öğe':1} > > > > >>> u'öğe' in test_dict.keys() > > > > True > > > > >>> 'öğe' in test_dict.keys() > > > > True > > > > I would call this a bug. The

Re: Unicode and dictionaries

2010-01-16 Thread Ben Finney
Carl Banks writes: > On Jan 16, 3:56 pm, Ben Finney wrote: > > gizli writes: > > > >>> test_dict = {u'öğe':1} > > > >>> u'öğe' in test_dict.keys() > > > True > > > >>> 'öğe' in test_dict.keys() > > > True > > > > I would call this a bug. The two objects are different, so the latter > > expressi

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
On Jan 16, 5:38 pm, Carl Banks wrote: > On Jan 16, 3:58 pm, Steven D'Aprano cybersource.com.au> wrote: > > On Sat, 16 Jan 2010 15:35:05 -0800, gizli wrote: > > > Hi all, > > > > I am using Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41). I ran > > > into this issue yesterday and wanted to

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
On Jan 16, 3:56 pm, Ben Finney wrote: > gizli writes: > > >>> test_dict = {u'öğe':1} > > >>> u'öğe' in test_dict.keys() > > True > > >>> 'öğe' in test_dict.keys() > > True > > I would call this a bug. The two objects are different, so the latter > expression should return ‘False’. Except the two

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
On Jan 16, 3:58 pm, Steven D'Aprano wrote: > On Sat, 16 Jan 2010 15:35:05 -0800, gizli wrote: > > Hi all, > > > I am using Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41). I ran > > into this issue yesterday and wanted  to check to see if this is a > > python bug. It seems that there is an i

Re: Unicode and dictionaries

2010-01-16 Thread Steven D'Aprano
On Sat, 16 Jan 2010 15:35:05 -0800, gizli wrote: > Hi all, > > I am using Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41). I ran > into this issue yesterday and wanted to check to see if this is a > python bug. It seems that there is an inconsistency between lists and > dictionaries in the

Unicode and dictionaries

2010-01-16 Thread gizli
Hi all, I am using Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41). I ran into this issue yesterday and wanted to check to see if this is a python bug. It seems that there is an inconsistency between lists and dictionaries in the way that unicode objects are handled. Take a look at the foll