Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39180
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <msirenef@lightbird.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'key.': 0.07; 'though:': 0.07; 'dict': 0.09; 'objects.': 0.09; 'python:': 0.09; 'runtime': 0.09; 'assume': 0.11; 'ah,': 0.16; 'appear.': 0.16; 'effect,': 0.16; 'hashes': 0.16; 'immutable,': 0.16; 'iterating': 0.16; "key's": 0.16; 'key?': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'unequal': 0.16; 'wrote:': 0.17; 'comparing': 0.17; '>>>': 0.18; 'supposed': 0.21; 'keys': 0.22; 'second': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'equality': 0.29; 'hash': 0.29; 'key,': 0.29; 'definition': 0.29; 'objects': 0.29; "i'm": 0.29; 'print': 0.32; 'certain': 0.33; 'to:addr:python-list': 0.33; 'equal': 0.33; 'that,': 0.34; 'changed': 0.34; 'thanks': 0.34; 'mapping': 0.35; 'pm,': 0.35; "won't": 0.35; 'there': 0.35; 'but': 0.36; 'data.': 0.36; 'subject:with': 0.36; 'should': 0.36; 'does': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'little': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'first': 0.61; 'stay': 0.61; 'time,': 0.62; 'different': 0.63; 'friends': 0.83; 'different.': 0.84; 'front.': 0.84; 'oscar': 0.84; 'angel': 0.93 |
| Date | Mon, 18 Feb 2013 22:56:40 -0500 |
| From | Mitya Sirenef <msirenef@lightbird.net> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Dictionaries with tuples or tuples of tuples |
| References | <c8abdc96-a47c-462a-9d6e-fcbaad1102fe@googlegroups.com> <mailman.1990.1361237726.2939.python-list@python.org> <3752f235-1542-44c8-b7c7-93dfd98eac3f@googlegroups.com> <dc54beb6-3949-4ab3-9c3d-90d264faa1e2@googlegroups.com> <5122E95B.1070600@lightbird.net> <5122EDFD.8000200@davea.name> |
| In-Reply-To | <5122EDFD.8000200@davea.name> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2004.1361246208.2939.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361246208 news.xs4all.nl 6909 [2001:888:2000:d::a6]:51604 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39180 |
Show key headers only | View raw
On 02/18/2013 10:14 PM, Dave Angel wrote: > On 02/18/2013 09:54 PM, Mitya Sirenef wrote: >> On 02/18/2013 09:17 PM, Jon Reyes wrote: >>> Thanks Dave and Mitya for enlightening me about dictionaries. I'm >>> still confused about this though: >> > >> > " so that if two >> > key objects are equal, they stay equal, and if they differ, they stay >> > different. " >> > >> > What does this mean? I won't be comparing key objects with one >> another. Also, when I had two keys with the same value the value of the >> other key disappeared so I assume in runtime if there are multiple keys >> of the same value only the last one will appear. >> >> You won't be, but dict will. >> >> Dict is by definition a mapping where a value is assigned to a unique >> key. If you have two keys and two values, and then change one key to >> be equal to the second key, that's not kosher, because which value it's >> supposed to return when you try to get it by that key? >> >> So in effect, key's hash value should not change. If key is immutable, >> you can be certain that it's hash value will not change. If it's >> mutable, you have to make sure not to change the key in a way that'd >> make its hash value different than it was. >> >> -m >> > > It's a little stronger than that, since equal hashes cannot assure > equal data. The equality of each object pair in a dict must not > change over time, not just the hashes of the individual objects. > Ah, yes - that's true; if hashes were unequal and then the key is changed to be equal to the first key, both mydict[key1] and mydict[key2] will give you value1, but iterating over dict items will print key1, value1; key2, value2. And that's not a good thing. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ True friends stab you in the front. Oscar Wilde
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 16:52 -0800
Re: Dictionaries with tuples or tuples of tuples Mitya Sirenef <msirenef@lightbird.net> - 2013-02-18 20:11 -0500
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 17:19 -0800
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 17:19 -0800
Re: Dictionaries with tuples or tuples of tuples Roy Smith <roy@panix.com> - 2013-02-18 20:17 -0500
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 17:20 -0800
Re: Dictionaries with tuples or tuples of tuples Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-19 01:37 +0000
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 17:38 -0800
Re: Dictionaries with tuples or tuples of tuples Dave Angel <davea@davea.name> - 2013-02-18 20:51 -0500
Re: Dictionaries with tuples or tuples of tuples Mitya Sirenef <msirenef@lightbird.net> - 2013-02-18 20:56 -0500
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 18:17 -0800
Re: Dictionaries with tuples or tuples of tuples Mitya Sirenef <msirenef@lightbird.net> - 2013-02-18 21:54 -0500
Re: Dictionaries with tuples or tuples of tuples Dave Angel <davea@davea.name> - 2013-02-18 22:14 -0500
Re: Dictionaries with tuples or tuples of tuples Mitya Sirenef <msirenef@lightbird.net> - 2013-02-18 22:56 -0500
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 18:17 -0800
Re: Dictionaries with tuples or tuples of tuples Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-19 02:34 +0000
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 18:39 -0800
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 18:39 -0800
Re: Dictionaries with tuples or tuples of tuples Jon Reyes <everystepsayes@gmail.com> - 2013-02-18 17:38 -0800
csiph-web