[Tutor] A couple of somewhat esoteric questions
Dave Angel
davea at davea.name
Thu Oct 23 03:22:53 CEST 2014
Dave Angel <davea at davea.name> Wrote
in message:
> "Clayton Kirkwood" <crk at godblessthe.us> Wrote in message:
>>
>>
>> !-----Original Message-----
>> !From: Tutor [mailto:tutor-bounces+crk=godblessthe.us at python.org] On
>> !Behalf Of Steven D'Aprano
> ...
>>
>> For clarification, a key only has one value which can be changed.
>
> No, because the key has to be immutable, like a string or an int.
My error for reading your statement wrong.
>
>> Multiple
>> keys can have the same value (hopefully not to the same memory location,
>> because one would usually not want the change of one key's value to alter
>> another key's value. As to the hash table, yes, I agree that this would be
>> one to many, hence the chains.
>
> Memory locations are an implementation detail. We're talking in
> this paragraph about keys and values. A value is an object, the
> dict provides a one-way mapping from immutable key to an
> arbitrary value object. If the value objects happen to be
> immutable, it makes no difference if a program uses the same
> value for multiple keys. If the values are not immutable, python
> makes no assurance whether two values are equal, or identical. If
> the latter is undesirable for a particular use, it's up to the
> application logic to prevent it. It's probably more often useful
> than problematic. Python makes no such assurances.
>
>
>
>
>
>> !Can you give a concrete example of what you're trying to do?
>>
>> The changing of the order is necessary when you want numeric indexing, say
>> for columns or rows.
>>
>
> No idea how this relates to dicts, which have no order, nor rows
> nor columns. Make it concrete.
>
>
> --
> DaveA
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>
--
DaveA
More information about the Tutor
mailing list