Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78600

Assignment Operators?

Newsgroups comp.lang.python
Date 2014-10-02 06:24 -0700
Message-ID <9669f493-cfa4-4a84-9f4a-ce3009926ca3@googlegroups.com> (permalink)
Subject Assignment Operators?
From Didymus <lynto28@gmail.com>

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Assignment Operators? Didymus <lynto28@gmail.com> - 2014-10-02 06:24 -0700
  Re: Assignment Operators? Chris Angelico <rosuav@gmail.com> - 2014-10-02 23:27 +1000
    Re: Assignment Operators? Grant Edwards <invalid@invalid.invalid> - 2014-10-02 14:23 +0000
  Re: Assignment Operators? Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-02 10:00 -0600
  Re: Assignment Operators? sohcahtoa82@gmail.com - 2014-10-06 14:37 -0700

csiph-web