Dict when defining not returning multi value key error
Dan Stromberg
drsalists at gmail.com
Thu Jul 31 23:12:12 EDT 2014
On Thu, Jul 31, 2014 at 8:08 PM, Dan Stromberg <drsalists at gmail.com> wrote:
>> p = {'1':"value0",'1.0':"value1"}
> For 1 and 1.0 - they simply hash differently. Dictionaries are
> resizeable hash tables.
I removed some quotes, and noticed that 1 and 1.0 hash the same.
That's a bit unexpected, but I suppose it's not completely
unreasonable.
EG:
$ pythons 'print("%s %s" % (hash(1), hash(1.0)))'
/usr/local/cpython-2.4/bin/python 1 1
/usr/local/cpython-2.5/bin/python 1 1
/usr/local/cpython-2.6/bin/python 1 1
/usr/local/cpython-2.7/bin/python 1 1
/usr/local/cpython-3.0/bin/python 1 1
/usr/local/cpython-3.1/bin/python 1 1
/usr/local/cpython-3.2/bin/python 1 1
/usr/local/cpython-3.3/bin/python 1 1
/usr/local/cpython-3.4/bin/python 1 1
/usr/local/pypy-2.3.1/bin/pypy 1 1
/usr/local/pypy3-2.3.1/bin/pypy 1 1
/usr/local/jython-2.7b2/bin/jython 1 1
More information about the Python-list
mailing list