semantics of the |= operator

Fredrik Lundh fredrik at pythonware.com
Fri Aug 22 03:56:35 EDT 2008


akva wrote:

> could you please refer me a link where this is specified? I couldn't
> find it in python documentation

http://docs.python.org/ref/augassign.html

"An augmented assignment expression like x += 1 can be rewritten as x = 
x + 1 to achieve a similar, but not exactly equal effect. In the 
augmented version, x is only evaluated once. Also, when possible, the 
actual operation is performed in-place, meaning that rather than 
creating a new object and assigning that to the target, the old object 
is modified instead."

</F>




More information about the Python-list mailing list