title: How do "and" and "or" work when combined in one statement?
body: <p>For some reason this function confused me:</p>
  
  <pre><code>def protocol(port):
      return port == "443" and "https://" or "http://"
  </code></pre>
  
  <p>Can somebody explain the order of what's happening behind the scenes to make this work the way it does.</p>
  
  <p>I understood it as this until I tried it:</p>
  
  <p>Either A)</p>
  
  <pre><code>def protocol(port):
      if port == "443":
          if bool("https://"):
              return True
      elif bool("http://"):
          return True
      return False
  </code></pre>
  
  <p>Or B)</p>
  
  <pre><code>def protocol(port):
      if port == "443":
          return True + "https://"
      else:
          return True + "http://"
  </code></pre>
  
  <p>Is this some sort of special case in Python, or am I completely misunderstanding how statements work?</p>