Re: [Python-3000] Detecting conflicts in dict displays

2006-07-28 Thread Josiah Carlson
"Stian Soiland" <[EMAIL PROTECTED]> wrote: > > On 7/11/06, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > >>> d={1:'one', 1.0:'one'} > > >>> d > > {1: 'one'} > > This highlights the problem. Imagine that you don't type out the > actual objects, but just receive them: > > def make_dict(x, y, obj)

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-28 Thread Stian Soiland
On 7/11/06, Terry Reedy <[EMAIL PROTECTED]> wrote: > >>> d={1:'one', 1.0:'one'} > >>> d > {1: 'one'} This highlights the problem. Imagine that you don't type out the actual objects, but just receive them: def make_dict(x, y, obj): return {x: obj, y: obj} x1 = x2 = "fish" d = make_dict(x1, x

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-14 Thread Aaron Bingham
Fredrik Lundh wrote: >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

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-13 Thread Fredrik Lundh
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]

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-13 Thread Guido van Rossum
On 7/13/06, Aaron Bingham <[EMAIL PROTECTED]> wrote: [Quoting someone else] > >> Maybe. Like that, sure. But what about: > >> > >> a = {a: 1, b: 2} > >> > >> where 'a' and 'b' happen to be equal (or equal enough for dicts)? I'd > >> rather leave this kind of checking up to pycheker or pylint (whic

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-13 Thread Aaron Bingham
Raymond Hettinger wrote: > Thomas Wouters wrote: > >> >> >> On 7/11/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 r

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-11 Thread Raymond Hettinger
Thomas Wouters wrote: On 7/11/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. Maybe. Like that, sure. But what about:  a = {a: 1, b: 2}

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-11 Thread Thomas Wouters
On 7/11/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.Maybe. Like that, sure. But what about: a = {a: 1, b: 2} where 'a' and 'b' happen to be equal (or equal enough f

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-11 Thread Terry Reedy
"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

Re: [Python-3000] Detecting conflicts in dict displays

2006-07-10 Thread Steven Bethard
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. > If people

[Python-3000] Detecting conflicts in dict displays

2006-07-10 Thread Guido van Rossum
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 people agree, what should we do with a = {'a': 1, 'a': 1} ??? In ABC, that's legal (and the first one is indeed an error; I took a shortcut when I decided