Unicode and dictionaries
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Jan 16 18:58:14 EST 2010
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 way that unicode objects are handled. Take a look at
> the following example:
>
>>>> test_dict = {u'öğe':1}
>>>> u'öğe' in test_dict.keys()
> True
>>>> 'öğe' in test_dict.keys()
> True
I can't reproduce your result, at least not in 2.6.1:
>>> test_dict = {u'öğe':1}
>>> u'öğe' in test_dict.keys()
True
>>> 'öğe' in test_dict.keys()
__main__:1: UnicodeWarning: Unicode equal comparison failed to convert
both arguments to Unicode - interpreting them as being unequal
False
--
Steven
More information about the Python-list
mailing list