Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93066
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Marko Rauhamaa <marko@pacujo.net> |
| Newsgroups | comp.lang.python |
| Subject | Re: Looking up a dictionary _key_ by key? |
| Date | Wed, 24 Jun 2015 09:55:51 +0300 |
| Organization | A noiseless patient Spider |
| Lines | 18 |
| Message-ID | <87a8vpmw7c.fsf@elektro.pacujo.net> (permalink) |
| References | <CAGGBd_pd9SA7SczanGARFr-+Z9SxP9Mkhfo-RivpcJLrnuexng@mail.gmail.com> <851th2t05t.fsf@benfinney.id.au> <CAGGBd_qaNC38Yg0u_b8+qBAckq6FRTZMxbWwuzV=MUYE_=ZzDw@mail.gmail.com> <mailman.3.1435107726.3674.python-list@python.org> <87a8vpykwq.fsf@nightsong.com> <mailman.7.1435128694.3674.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="21064"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18k9A+nYielqZh3wbv4i0JI" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Cancel-Lock | sha1:MbmJva4Nb8nI3r8S5o3WWEcT5qU= sha1:7A/xKxldTi9dP/1XJ1FDd1vt5gk= |
| Xref | csiph.com comp.lang.python:93066 |
Show key headers only | View raw
Ian Kelly <ian.g.kelly@gmail.com>:
> I don't think that it's fundamentally broken. A simple example would
> be the int 3, vs. the float 3, vs. the Decimal 3. All of them compare
> equal to one another, but they are distinct values, and sometimes it
> might be useful to be able to determine which one is actually a key in
> the dict.
One possibility is to enter the key on the value side as well:
d[key] = (key, value)
...
canonical_key, value = d[key]
Marko
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Looking up a dictionary _key_ by key? Chris Angelico <rosuav@gmail.com> - 2015-06-24 11:02 +1000
Re: Looking up a dictionary _key_ by key? Paul Rubin <no.email@nospam.invalid> - 2015-06-23 18:06 -0700
Re: Looking up a dictionary _key_ by key? Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-24 00:50 -0600
Re: Looking up a dictionary _key_ by key? Marko Rauhamaa <marko@pacujo.net> - 2015-06-24 09:55 +0300
Re: Looking up a dictionary _key_ by key? Laura Creighton <lac@openend.se> - 2015-07-05 08:25 +0200
csiph-web