title: How to give an error when no options are given with optparse
body: <p>I'm try to work out how to use optparse, but I've come to a problem.</p>
  
  <p>My script (represented by this simplified example) takes a file, and does different things to it depending on options that are parsed to it. If no options are parsed nothing is done.</p>
  
  <p>It makes sense to me that because of this, an error should be given if no options are given by the user. I can't work out how to do this.</p>
  
  <p>I've read that options should be optional and not required. Does this mean I am using options in the wrong way? If so, how should I be doing it instead? I can't see any other way of going about it.</p>
  
  <pre><code>#!/usr/bin/python
  
  from optparse import OptionParser
  
  dict = {'name': foo, 'age': bar}
  
  parser = OptionParser()
  
  parser.add_option("-n", "--name", dest="name")
  parser.add_option("-a", "--age", dest="age")
  
  (options, args) = parser.parse_args()
  
  if options.name:
      dict['name'] = options.name
  
  if options.age:
      dict['age'] = options.age
  
  print dict
  
  #END
  </code></pre>