[issue17022] Inline assignment uses the newly created object

R. David Murray report at bugs.python.org
Fri Feb 1 15:35:03 CET 2013


R. David Murray added the comment:

Well, it is consistent with plain reasoning if you remember that (a) python is a dynamic language and (b) python assignments do not return values (this is a core principle in the language design), which means that (c) the chained assignment form is a shorthand.  Of course, you do then have to look up what it is a shorthand *for*, but if you approached another language's chained assignment with a Python mindset, you'd also have to look it up to find out what rules applied to that language.

It is hard not to make assumptions based on other languages you've learned.  Interestingly, when I did a quick google for what other languages do for chained assignment I didn't come up with much.  Looks like most don't support it, or if they do they do so as a side effect of an assignment returning a value.

So, yes, Python is a unique language.  There are usually good underlying reasons for the various design decision made (not always, but very very often).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17022>
_______________________________________


More information about the Python-bugs-list mailing list