Message180511
> Python is designed to be unsurprising; constructs generally mean
> what it looks like they mean.
AFAIK in C "x += 1" is equivalent to "x++", and both are semantically more about incrementing (mutating) the value of x than about creating a new value that gets assigned to x.
Likewise it seems to me more natural to interpret "x += y" as "add the value of y to the object x" than "add x and y together and save the result in x".
Clearly if you are used to other languages with different semantics you might expect a different behavior, but you could say the same about the fact that int/int gives float on Python 3: it's surprising if you are used to other languages like C, but otherwise it's more natural.
> I interpreted this paragraph wrongly, because I interpreted it in the
> only way that made sense given the meaning of these operators in
> every other language that has them.
It seems to me that the documentation doesn't leave much room for interpretation regarding the fact that the object is mutated in place; the only problem is that it doesn't specify clearly what are the objects that do this. |
|
Date |
User |
Action |
Args |
2013-01-24 06:22:22 | ezio.melotti | set | recipients:
+ ezio.melotti, r.david.murray, docs@python, benrg, ashwch |
2013-01-24 06:22:22 | ezio.melotti | set | messageid: <1359008542.86.0.495095094533.issue16701@psf.upfronthosting.co.za> |
2013-01-24 06:22:22 | ezio.melotti | link | issue16701 messages |
2013-01-24 06:22:22 | ezio.melotti | create | |
|