[Python-Dev] chained assignment weirdity
Ned Batchelder
ned at nedbatchelder.com
Tue Nov 6 20:00:17 CET 2012
On 11/6/2012 1:19 PM, Devin Jeanpierre wrote:
>
>
> On Nov 6, 2012 1:05 PM, "Ned Batchelder" <ned at nedbatchelder.com
> <mailto:ned at nedbatchelder.com>> wrote:
> >
> > On 11/6/2012 11:26 AM, R. David Murray wrote:
> >>
> >> On Tue, 06 Nov 2012 18:14:38 +0200, Serhiy Storchaka
> <storchaka at gmail.com <mailto:storchaka at gmail.com>> wrote:
> >>>
> >>> Another counterintuitive (and possible wrong) example:
> >>>
> >>> >>> {print('foo'): print('bar')}
> >>> bar
> >>> foo
> >>> {None: None}
> >>
> >> http://bugs.python.org/issue11205
> >
> >
> > This seems to me better left undefined, since there's hardly ever a
> need to know the precise evaluation sequence between keys and values,
> and retaining some amount of "unspecified" to allow for implementation
> flexibility is a good thing.
>
> "Left undefined"? The behavior was defined, but CPython didn't follow
> the defined behaviour.
>
I would change the reference manual to leave it undefined. Clearly not
many people have been bothered by the fact that CPython implemented it
"wrong". If someone really needs to control whether the keys or values
are evaluated first, they shouldn't use a dict literal.
--Ned.
> --Devin (phone)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20121106/0a5b1d93/attachment.html>
More information about the Python-Dev
mailing list