"Steven Bethard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 7/10/06, Guido van Rossum <[EMAIL PROTECTED]> wrote:
>> Currently, this is valid:
>>
>> a = {'a': 1, 'a': 2}
>> print a # {'a': 2}
>>
>> I wonder if we shouldn't make this a run-time error instead.
>
> If it's possible, definitely. That's gotta be a typo if it appears in
> real code.
I think it would overall be helpful to tell people "duplicate key 'a'"
>> If people agree, what should we do with
>>
>> a = {'a': 1, 'a': 1}
>>
>> ???
>
> It should also be an error. I can't imagine that not being a typo.
> And there isn't really any reason to write that since we're talking
> dict literals here.
Something effectively the same could also be an act of ignorance:
>>> d={1:'one', 1.0:'one'}
>>> d
{1: 'one'}
I think this should be caught also. The exception message is a bit
trickier here.
Terry Jan Reedy
_______________________________________________
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