[Python-ideas] PEP
Westley MartÃnez
anikom15 at gmail.com
Fri Mar 9 00:00:06 CET 2012
On Thu, Mar 08, 2012 at 02:08:23PM -0700, Mark Janssen wrote:
> On Thu, Feb 9, 2012 at 5:18 PM, Guido van Rossum <guido at python.org> wrote:
>
> > A dictionary would (then) be a SET of these. (Voila! things have already
> >> gotten simplified.)
> >>
> >
> > Really? So {a:1, a:2} would be a dict of length 2?
> >
>
> Eventually, I also think this will seque and integrate nicely into Mark
> >> Shannon's "shared-key dict" proposal (PEP 412).
> >>
> >>
> I just noticed something in Guido's example. Something gives me a strange
> feeling that using a variable as a key doesn't smell right. Presumably
> Python just hashes the variable's id, or uses the id itself as the key, but
> I wonder if anyone's noticed any problems with this, and whether the hash
> collision problems could be solved by removing this?? Does anyone even
> use this functionality -- of a *variable* (not a string) as a dict key?
>
> mark
Using a variable as a key is valid since the object itself is used for
a key. There've been times when I've used ints as keys but beyond that
nothing else (besides strings).
More information about the Python-ideas
mailing list