Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
roelschroeven
on Oct 11, 2021
|
parent
|
context
|
favorite
| on:
Understanding Python through its builtins
The inconsistency is that for immutable objects (or more generally, objects that have __add__ but not __iadd__), '+=' does create a name binding.
After 'a = 300; b = 50000',
a += b
is exactly the same as
a = a + b
In this case, a new object is created with the value of a + b which then gets bound to the name a.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
After 'a = 300; b = 50000',
is exactly the same as In this case, a new object is created with the value of a + b which then gets bound to the name a.