Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75456

Re: Dict when defining not returning multi value key error

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drsalists@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'subject:not': 0.03; 'suppose': 0.07; '%s"': 0.09; 'dan': 0.09; 'differently.': 0.09; 'cc:addr:python-list': 0.11; 'cc:name:python list': 0.16; 'dictionaries': 0.16; 'subject:key': 0.16; 'subject:when': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'thu,': 0.19; 'cc:addr:python.org': 0.22; '31,': 0.24; 'skip:{ 20': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'noticed': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'same.': 0.38; 'pm,': 0.38; 'skip:u 10': 0.60; 'simply': 0.61; 'to:addr:gmail.com': 0.65; 'jul': 0.74; 'skip:/ 30': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=7WTVi/k7RgjXtCG85dO15waDWf8x5HpT5uvPcW2sPc0=; b=SuhB6knqdIGpHRvMHvmTshu3nSewOBdsvEapF2Sf8LVrctCRwJrXqFYBZFqFMZQKk0 8TspRa+uv/lhvfYMt2CltNG3YUQb7AYKDg1oYS9s4cHtt/wfrws1bbkvKEGsxgIj1k7X 3Cp1iZHfNsYJofg0QiPlP4+KnckWCmVEmyX8CCWMLStupYOrvAe1upoDmELz53e3hGlJ WpXdCu08EA4Eb5ISF8vleKKMyD/QRoXj+96+Tb+DwlH2RFhtE6YDpdI2ulAQL/DlObfU M3vq8Lqoi8apAk4dzb6GHuGBp0GDJg+hqMbdZFpkE6mYq4l3eGP8Bl2EknfpFchm7Gs7 G6jg==
MIME-Version 1.0
X-Received by 10.236.131.109 with SMTP id l73mr3611238yhi.96.1406862732883; Thu, 31 Jul 2014 20:12:12 -0700 (PDT)
In-Reply-To <CAGGBd_riruS0nRM9+o+1dz=jVZgYOo09qX97P+LWK5Nu6HTYRw@mail.gmail.com>
References <CAFBK5a-hjukHaHOim4tL_RerXiHsFP03eaQoN42yGfeCJ9NZPg@mail.gmail.com> <CAGGBd_riruS0nRM9+o+1dz=jVZgYOo09qX97P+LWK5Nu6HTYRw@mail.gmail.com>
Date Thu, 31 Jul 2014 20:12:12 -0700
Subject Re: Dict when defining not returning multi value key error
From Dan Stromberg <drsalists@gmail.com>
To Dilu Sasidharan <dilu.seven@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc Python List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12501.1406862741.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406862741 news.xs4all.nl 2879 [2001:888:2000:d::a6]:58864
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75456

Show key headers only | View raw


On Thu, Jul 31, 2014 at 8:08 PM, Dan Stromberg <drsalists@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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Dict when defining not returning multi value key error Dan Stromberg <drsalists@gmail.com> - 2014-07-31 20:12 -0700
  Re: Dict when defining not returning multi value key error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-01 04:04 +0000
    Re: Dict when defining not returning multi value key error Ben Finney <ben+python@benfinney.id.au> - 2014-08-01 14:17 +1000
      Re: Dict when defining not returning multi value key error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-01 13:31 +0000
        Re: Dict when defining not returning multi value key error Chris Angelico <rosuav@gmail.com> - 2014-08-01 23:57 +1000
          Re: Dict when defining not returning multi value key error Marko Rauhamaa <marko@pacujo.net> - 2014-08-01 18:39 +0300
            Re: Dict when defining not returning multi value key error Terry Reedy <tjreedy@udel.edu> - 2014-08-01 17:42 -0400
            Re: Dict when defining not returning multi value key error Chris Angelico <rosuav@gmail.com> - 2014-08-02 09:57 +1000
              Re: Dict when defining not returning multi value key error Marko Rauhamaa <marko@pacujo.net> - 2014-08-02 09:41 +0300
                Re: Dict when defining not returning multi value key error Marko Rauhamaa <marko@pacujo.net> - 2014-08-02 10:06 +0300
                Re: Dict when defining not returning multi value key error Chris Angelico <rosuav@gmail.com> - 2014-08-02 20:58 +1000
            Re: Dict when defining not returning multi value key error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-02 11:47 +1000
              Re: Dict when defining not returning multi value key error Chris Angelico <rosuav@gmail.com> - 2014-08-02 12:13 +1000

csiph-web