title: How can I process command line arguments in Python?
body: <p>What would be an easy expression to process command line arguments if I'm expecting anything like 001 or 999 (let's limit expectations to 001...999 range for this time), and few other arguments passed, and would like to ignore any unexpected?</p>
  
  <p>I understand if for example I need to find out if "debug" was passed among parameters it'll be something like that:</p>
  
  <pre><code>if 'debug' in argv[1:]:
    print 'Will be running in debug mode.'
  </code></pre>
  
  <p>How to find out if 009 or 575 was passed?</p>
  
  <p>All those are expected calls:</p>
  
  <pre><code>python script.py
  python script.py 011
  python script.py 256 debug
  python script.py 391 xls
  python script.py 999 debug pdf
  </code></pre>
  
  <p>At this point I don't care about calls like that:</p>
  
  <pre><code>python script.py 001 002 245 568
  python script.py some unexpected argument
  python script.py 0001
  python script.py 02
  </code></pre>
  
  <p>...first one - because of more than one "numeric" argument; second - because of... well, unexpected arguments; third and fourth - because of non-3-digits arguments.</p>