title: Python boolean list with fixed-ordered elements
body: <p>I am trying to make some binary singal system by boolean variables I named with LIGHTx.</p>
  
  <pre><code>LIGHT1 = True
  LIGHT2 = True
  LIGHT3 = False
  LIGHT4 = False
  </code></pre>
  
  <p>Next, I nest these variables into a list for future calculation,</p>
  
  <pre><code>signal = [LIGHT1, LIGHT2, LIGHT3, LIGHT4]
  </code></pre>
  
  <p>Currently I am using the idea from <a href="https://stackoverflow.com/questions/22056486/python-boolean-list-to-binary-string">Python: Boolean List to Binary String</a> and <a href="https://stackoverflow.com/questions/8928240/convert-base-2-binary-number-string-to-int">Convert base-2 binary number string to int</a> to convert the list to int number which is my signal. Here, [1,1,0,0] means 12.</p>
  
  <pre><code>In [97]: boolList2BinString(signal)
  Out[97]: 12
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li>How can I automatically updating the elements of "signal" by updating the value of the LIGHTs, rather than running <code>signal = [LIGHT1, LIGHT2, LIGHT3, LIGHT4]</code> again and again? Whitch means, in the rest of my codes, I only need to run <code>LIGHTx = xxxx</code> and <code>boolList2BinString(signal)</code>. (Maybe some way like pointer of C++ ?)</li>
  <li>If it is impossible with question 1, is there any way that I can fix the order of the LIGHTs in the list?</li>
  </ol>
  
  <p><strong>[Update]</strong></p>
  
  <p>Please <strong>exclude</strong> the way that building the 'signal' list inside the 'boolList2BinString' function. </p>
  
  <p>Original:</p>
  
  <pre><code>def boolList2BinString(lst):
      return int('0b' + ''.join(['1' if x else '0' for x in lst]), 2)
  </code></pre>
  
  <p>Building inside:</p>
  
  <pre><code>def boolList2BinString():
      osignal = [LIGHT1 , LIGHT2 , LIGHT3 , LIGHT4 ]
      return int('0b' + ''.join(['1' if x else '0' for x in signal ]), 2)
  </code></pre>
  
  <p>Thanks in advance!</p>