title: Can anyone explain the "guardian pattern" to me
body: <p>Tried searching for guardian pattern but I couldn't find anything that answered my question so here I am again. In the book I am reading the author uses a line of code that he calls, "the guardian pattern" and I don't really understand how it works. here is the example and I would be grateful if someone could explain it to me.</p>
  
  <pre><code>while True:
      line = raw_input('&gt; ')
      if len(line) &gt; 0 and line[0] == '#' :
          continue
      if line == 'done':
          break
      print line
  print "done!"
  </code></pre>
  
  <p>so why, if the length of the line > 0 and line[0] == '#' :
  does it not error if I just hit enter with nothing there. Wouldn't the line be 0 and thus line isn't > 0? if you put the orig code in which is </p>
  
  <pre><code>if line[0] == '#' : 
  </code></pre>
  
  <p>it errors out when you just hit enter.</p>