Prevent threading.Thread.join() from blocking when a previous call raised an
[python.git] / Doc / lib / required_1.py
blob6be5668eee960c4d145b34872689c88b3855e69a
1 import optparse
3 class OptionParser (optparse.OptionParser):
5 def check_required (self, opt):
6 option = self.get_option(opt)
8 # Assumes the option's 'default' is set to None!
9 if getattr(self.values, option.dest) is None:
10 self.error("%s option not supplied" % option)
13 parser = OptionParser()
14 parser.add_option("-v", action="count", dest="verbose")
15 parser.add_option("-f", "--file", default=None)
16 (options, args) = parser.parse_args()
18 print "verbose:", options.verbose
19 print "file:", options.file
20 parser.check_required("-f")