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: 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: References: Date: Thu, 31 Jul 2014 20:12:12 -0700 Subject: Re: Dict when defining not returning multi value key error From: Dan Stromberg To: Dilu Sasidharan Content-Type: text/plain; charset=UTF-8 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Thu, Jul 31, 2014 at 8:08 PM, Dan Stromberg 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