3 Suggestions to Make Python Easier For Children

MRAB python at mrabarnett.plus.com
Tue Aug 5 10:11:29 EDT 2014


On 2014-08-05 14:19, Marko Rauhamaa wrote:
> Skip Montanaro <skip at pobox.com>:
>
>> On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> I wonder if that should be built into dict.
>>
>> Short answer, no. I'm sure it's been proposed before. Attributes ≠
>> keys. When you see something.somethingelse anywhere else in Python,
>> "somethingelse" is an attribute reference. When you see
>> something[somethingelse], "somethingelse" is an index value or key.
>> Why destroy that symmetry in dictionaries?
>
> I'm not sure I fully appreciate the dichotomy (which you euphemistically
> refer to as symmetry).
>
>> JavaScript objects have that feature. I find it mildly confusing
>> because whenever I see it I have to pause to consider whether the name
>> I am looking at is an attribute or a key.
>
> What's the inherent difference between an attribute and a key.
>
An attribute is part of a container; a key is part of its contents.




More information about the Python-list mailing list