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


Groups > comp.lang.python > #75457 > unrolled thread

Re: Dict when defining not returning multi value key error

Started byTerry Reedy <tjreedy@udel.edu>
First post2014-07-31 23:28 -0400
Last post2014-07-31 23:28 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Dict when defining not returning multi value key error Terry Reedy <tjreedy@udel.edu> - 2014-07-31 23:28 -0400

#75457 — Re: Dict when defining not returning multi value key error

FromTerry Reedy <tjreedy@udel.edu>
Date2014-07-31 23:28 -0400
SubjectRe: Dict when defining not returning multi value key error
Message-ID<mailman.12502.1406863728.18130.python-list@python.org>
On 7/31/2014 5:15 PM, Ian Kelly wrote:
> On Thu, Jul 31, 2014 at 5: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"}
>
> In this latter case note that '1' and '1.0' are not equal, so this
> will simply result in two separate entries in the dict anyway.

Dilu presumably meant
 >>> p = {1:"value0", 1.0:"value1"}
 >>> p
{1: 'value1'}

-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web