Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section on Shorthand Operators not strictly true #99

Open
madphysicist opened this issue Aug 25, 2016 · 0 comments
Open

Section on Shorthand Operators not strictly true #99

madphysicist opened this issue Aug 25, 2016 · 0 comments

Comments

@madphysicist
Copy link

I am referring to http://pymbook.readthedocs.io/en/latest/operatorsexpressions.html#shorthand-operator. x op= y is not always equivalent to x = x op y. The statement is always true for immutable objects like ints and tuples. Mutable objects, on the other hand, can have a completely different implementation of the shorthand operators since those operators can modify the object in-place. For example, lists define a legitimately different __iadd__ operator (which is basically extend).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant