Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75455 > unrolled thread
| Started by | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| First post | 2014-07-31 20:08 -0700 |
| Last post | 2014-07-31 20:08 -0700 |
| 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.
Re: Dict when defining not returning multi value key error Dan Stromberg <drsalists@gmail.com> - 2014-07-31 20:08 -0700
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2014-07-31 20:08 -0700 |
| Subject | Re: Dict when defining not returning multi value key error |
| Message-ID | <mailman.12500.1406862508.18130.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web