A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-August/067994.html below:

unicode hell/mixing str and unicode asdictionarykeys

[Python-Dev] Dicts are broken Was: unicode hell/mixing str and unicode asdictionarykeysBob Ippolito bob at redivi.com
Fri Aug 4 22:23:20 CEST 2006
On Aug 4, 2006, at 12:51 PM, Giovanni Bajo wrote:

> Paul Colomiets <pc at gafol.net> wrote:
>
>> Well it's not recomended to mix strings and unicode in the
>> dictionaries
>> but if we mix for example integer and float we have the same  
>> thing. It
>> doesn't raise exception but still it is not expected behavior for me:
>>>>> d = { 1.0: 10, 2.0: 20 }
>> then if i somewhere later do:
>>>>> d[1] = 100
>>>>> d[2] = 200
>> to have here all floats in d.keys(). May be this is not a best
>> example.
>
> There is a strong difference. Python is moving towards unifying  
> number types in
> a way (see the true division issue): the idea is that, all in all,  
> user
> shouldn't really care what type a number is, as long as he knows  
> it's a number.
> On the other hand, unicode and str are going to diverge more and more.

Well, not really. True division makes int/int return float instead of  
an int. You really do have to care if you have an int or a float most  
of the time, they're very different semantically.

Unicode and str are eventually going to be the same thing (str would  
ideally end up becoming a synonym of unicode). The difference being  
that there will be some other type to contain bytes.

-bob

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4