Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75531
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Subject | Re: Dict when defining not returning multi value key error |
| Date | 2014-08-02 07:43 -0400 |
| References | <CAFBK5a-hjukHaHOim4tL_RerXiHsFP03eaQoN42yGfeCJ9NZPg@mail.gmail.com> <CALwzidmjo9OqDd0zqYB3Y94FsNZOn-8GoFy+L9YinyWu3v1zwg@mail.gmail.com> <lrf1gt$l9t$1@ger.gmane.org> <CALwzid=D3-YiYkdMh+UZ-gM3n6TNB_w=h8urBMF4oRoR2QESsQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12540.1406979844.18130.python-list@python.org> (permalink) |
On 8/1/14 10:30 AM, Ian Kelly wrote:
> On Thu, Jul 31, 2014 at 9:28 PM, Terry Reedy <tjreedy@udel.edu> wrote:
>> 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'}
>
> Maybe, but it was explicitly stated that the keys were strings.
>
You are right, my mistake. Apologies.
--
Ned Batchelder, http://nedbatchelder.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Dict when defining not returning multi value key error Ned Batchelder <ned@nedbatchelder.com> - 2014-08-02 07:43 -0400
csiph-web