Assignment Operators?

Didymus lynto28 at gmail.com
Thu Oct 2 09:24:25 EDT 2014


Hi All,

   I was wondering if someone could explain an assignment operator that I'm seeing in some code. As an example:

>>> errors = False
>>> errors |= 3
>>> errors 
3
>>> errors |= 4
>>> errors
7

   The '|=' operator, I read should be like a = a | b, but this appears to add the two numbers as long as it's more than the previous:

>>> errors |= 5
>>> errors
7

   Is there anywhere I can read up more on this and the other assignment operators and what/how they work. I got this off 

http://rgruet.free.fr/PQR27/PQR2.7.html


I'm using:
% python
Python 2.7.5 (default, Sep 25 2014, 13:57:38) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2


  Thanks for any help in advance.
   
     Tom



More information about the Python-list mailing list