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


Groups > comp.lang.python > #75455

Re: Dict when defining not returning multi value key error

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.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; 'string': 0.09; 'differently.': 0.09; 'immutable': 0.09; 'overwrite': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'cc:name:python list': 0.16; 'dict': 0.16; 'dictionaries': 0.16; 'for,': 0.16; 'ids.': 0.16; 'pair,': 0.16; 'subject:key': 0.16; 'subject:when': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'error': 0.23; '31,': 0.24; 'skip:{ 20': 0.24; 'cc:2**0': 0.24; 'define': 0.26; 'header:In- Reply-To:1': 0.27; 'wondering': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'actual': 0.34; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'returning': 0.36; 'hi,': 0.36; 'starting': 0.37; 'sometimes': 0.38; 'simply': 0.61; "you're": 0.61; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'jul': 0.74; 'behavior': 0.77; 'refuses': 0.84; 'shares': 0.93
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=gal6LPoyIcUSl5LaWp0FPulct9LAl/G/TdIN/koAA0g=; b=v0oECHCVRHdc3Ng62DfoftdHqWnguDPiI2jLHabamchCga/FNB6PbIEc+F40fFg/B9 oQQ9GXmIfi82nKcbuYiMqcksCo2iLIOh+DGDCOHaAJuIEFPsNodoVuI2wPT6l4+YQ9Bf qbqdIqeezt80+Dx2k2sCIayzpvuTeYx+MU2eBQq+aZhqGFAmF2QYlGuOZ7gZGfllcNCw CKXvuX8iDbpsebVutAXBZCMrYYc3BhLudSQUBYTRhFLXote14OT65t61HEcomd1oHlk7 XaxLQWLH0rubqaJqXsvJoHzE8iAUtXo47IaEdxT4tJdN5YHPvsEMQI+C4djzdfzkg41v LXUA==
MIME-Version 1.0
X-Received by 10.236.150.70 with SMTP id y46mr3517020yhj.52.1406862500188; Thu, 31 Jul 2014 20:08:20 -0700 (PDT)
In-Reply-To <CAFBK5a-hjukHaHOim4tL_RerXiHsFP03eaQoN42yGfeCJ9NZPg@mail.gmail.com>
References <CAFBK5a-hjukHaHOim4tL_RerXiHsFP03eaQoN42yGfeCJ9NZPg@mail.gmail.com>
Date Thu, 31 Jul 2014 20:08:20 -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.12500.1406862508.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406862508 news.xs4all.nl 2883 [2001:888:2000:d::a6]:56194
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75455

Show key headers only | View raw


On Thu, Jul 31, 2014 at 4:24 AM, Dilu Sasidharan <dilu.seven@gmail.com> wrote:
> Hi,
>
> I am wondering why the dictionary in python not returning multi value key
> error when i define something like
>
> p = {'k':"value0",'k':"value1"}
>
> key is string immutable and sometimes shares same id.
>
> also if the key is immutable and have different ids.
>
> like
>
> p = {'1':"value0",'1.0':"value1"}

If you want a dict that refuses to overwrite a key-value pair, you
could create one starting from
http://stackoverflow.com/questions/3387691/python-how-to-perfectly-override-a-dict
.  It's not an unreasonable behavior that you're looking for, but
neither is the actual behavior.

For 1 and 1.0 - they simply hash differently.  Dictionaries are
resizeable hash tables.

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


Thread

Re: Dict when defining not returning multi value key error Dan Stromberg <drsalists@gmail.com> - 2014-07-31 20:08 -0700

csiph-web