title: Global variable visibility depends on its name?
body: <p>Here is a puzzle I can't wrap my head around.</p>
  <p>The code below works:</p>
  <pre><code>CONST_TIME_SPEED1S = 4000
  CONST1_SPEED1S = 0.5
  CONST2_SPEED1S = 0.12
  CONST3_SPEED1S = 0.1
  DS_FLAPS_SLOW = 0
  DS_ERROR_F_NO_SPEED = 0
  
  Timer_Speed_1s = 0
  Direction = 'DIRECTION_LOWER'
  
  Flag_Flaps_Primary_Fault = 0
  
  def main_logic():
      if Direction == 'DIRECTION_LOWER':
          if Timer_Speed_1s &gt; CONST_TIME_SPEED1S:
              if (Speed1S &lt; CONST1_SPEED1S) and (Speed1S &gt; CONST2_SPEED1S):
                  DS_FLAPS_SLOW = 1
                  DS_ERROR_F_NO_SPEED = 0
              else:
                  DS_FLAPS_SLOW = 0
                  if Speed1S &lt; CONST3_SPEED1S:
                      DS_ERROR_F_NO_SPEED = 1
                      DS_FLAPS_PRIMARY_FAULT = 1
                  else:
                      DS_ERROR_F_NO_SPEED = 0
                      if Flag_Flaps_Primary_Fault == 1:
                          pass
                      else:
                          DS_FLAPS_PRIMARY_FAULT = 0
          else:
              DS_FLAPS_SLOW = 0
              DS_ERROR_F_NO_SPEED = 0
      else:
          Timer_Speed_1S = 0
          DS_FLAPS_SLOW = 0
          DS_ERROR_F_NO_SPEED = 0
          
  main_logic()
  
  print ('DS_FLAPS_SLOW = ', DS_FLAPS_SLOW)
  print ('DS_ERROR_F_NO_SPEED = ', DS_ERROR_F_NO_SPEED)
  </code></pre>
  <p>If I change name of the variable 'Timer_Speed_1s' into 'Timer_Speed_1S', I get a message &quot;UnboundLocalError: local variable 'Timer_Speed_1S' referenced before assignment&quot;.</p>
  <p>To puzzle me more, when I strip the code down to:</p>
  <pre><code>Timer_Speed_1S = 0
  
  def main_logic():
      print (Timer_Speed_1S)
             
  main_logic()
  </code></pre>
  <p>everything works just fine, no error messages.
  How can it be?</p>