Guido van Rossum wrote:

>> Wouldn't the behavior of the above be undefined for the case where a ==
>> b?  I'd much rather get an exception than undefined behavior.
>
> There's nothing undefined in the language currently about {a: 1, b:
> 2}. It creates an empty dict d, and then does d[a] = 1; d[b] = 2. If a
> and b are equal, you end up with {a: 2}.

for the formal definition, see "dictionary displays" in the language reference:

    The key/datum pairs are evaluated from left to right to define the
    entries of the dictionary: each key object is used as a key into the
    dictionary to store the corresponding datum. /.../

    Clashes between duplicate keys are not detected; the last datum
    (textually rightmost in the display) stored for a given key value pre-
    vails.

    ( http://pyref.infogami.com/dictionary-displays )

</F> 



_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to