Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:error': 0.03; 'subject:not': 0.03; 'suppose': 0.07; 'versions,': 0.07; 'dan': 0.09; 'expected.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '\xe2\x80\x94': 0.09; 'api': 0.11; 'python': 0.11; 'assume': 0.14; 'assumptions': 0.16; 'different,': 0.16; 'enough.': 0.16; 'finney': 0.16; 'mistake;': 0.16; 'next.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:key': 0.16; 'subject:when': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'thu,': 0.19; 'header:User-Agent:1': 0.23; 'versions': 0.24; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'correct': 0.29; '-0700,': 0.31; "d'aprano": 0.31; 'implied': 0.31; 'steven': 0.31; 'writes:': 0.31; 'there.': 0.32; 'run': 0.32; 'noticed': 0.34; 'equal': 0.35; 'objects': 0.35; 'but': 0.35; 'words,': 0.36; 'should': 0.36; 'two': 0.37; 'expected': 0.38; 'ben': 0.38; 'same.': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'expect': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'break': 0.61; "you're": 0.61; 'making': 0.63; 'different': 0.65; 'details': 0.65; 'between': 0.67; 'details,': 0.68; 'detail.': 0.68; 'jul': 0.74; 'hand': 0.80; 'attitude,': 0.84; 'received:125': 0.84; 'same,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Dict when defining not returning multi value key error Date: Fri, 01 Aug 2014 14:17:41 +1000 References: <53db11c1$0$29986$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:b4PR7gxCgi/I4ukEFN1R4vlLgPI= 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406866676 news.xs4all.nl 2906 [2001:888:2000:d::a6]:43387 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75459 Steven D'Aprano writes: > On Thu, 31 Jul 2014 20:12:12 -0700, Dan Stromberg wrote: > > > 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. I would expect it, for the reasons Steven explains. Why is it unexpected? > You should expect that two equal objects should hash to the same value > in different versions of Python, or even from one run of Python to the > next. I suspect there's a “not” missing there. To be explicit: You should not expect any particular comparisons to hold true for hash values between different Python versions, or even from one run to the next. Only those promises made or logically implied in the API should be expected. Implementation details should be expected to break assumptions — in other words, don't depend on any particular behaviour of an implementation detail. If you expect the hash valuesto be the same, you're making a mistake; if you expect the hash values to be different, you're making a mistake. The correct attitude, with regard to implementation details, is to expect uncertainty and not assume anything :-) -- \ “Natural catastrophes are rare, but they come often enough. We | `\ need not force the hand of nature.” —Carl Sagan, _Cosmos_, 1980 | _o__) | Ben Finney