title: Is this normally used/a good practice in Python?
body: <p>So, I've encountered this snippet in the code when digging a bit to check some logic behind states changes:</p>
  
  <pre><code>def doSomething(cls, state):
      state &amp;= ~CLOSED_STATE
      if (state &amp; OPEN_STATE) == 0:
          state |= ANOTHER_STATE
  
      return state
  </code></pre>
  
  <p>(where, CLOSED_STATE = 1, OPEN_STATE = 4, ANOTHER_STATE = 2)</p>
  
  <p>So, from a fairly beginner Python dev, it took me a few mins to understand what each line was doing, let alone understand the whole logic.</p>
  
  <p>I'm experience working with other languages, and if the idea is to just check some states logic and return something, I would never overcomplicate it using bitwise operations like that, but maybe its a common practice in Python, which I'm not knowledge of.</p>
  
  <p>Thanks.</p>