[Python-3000] Detecting conflicts in dict displays
Guido van Rossum
guido at python.org
Thu Jul 13 16:29:04 CEST 2006
On 7/13/06, Aaron Bingham <bingham at cenix-bioscience.com> 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 (which
> >> already check for quite a lot more than I'd want the Python runtime
> >> to check :)
> >
> > +1 for leaving this to PyLint or PyChecker.
>
> 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}.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list