mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
SF #642236, optparse LaTeX docs by Johannes Gijsbers
This commit is contained in:
parent
11f89b75e1
commit
488609e43a
6 changed files with 1821 additions and 0 deletions
20
Doc/lib/required_1.py
Executable file
20
Doc/lib/required_1.py
Executable file
|
@ -0,0 +1,20 @@
|
|||
import optparse
|
||||
|
||||
class OptionParser (optparse.OptionParser):
|
||||
|
||||
def check_required (self, opt):
|
||||
option = self.get_option(opt)
|
||||
|
||||
# Assumes the option's 'default' is set to None!
|
||||
if getattr(self.values, option.dest) is None:
|
||||
self.error("%s option not supplied" % option)
|
||||
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-v", action="count", dest="verbose")
|
||||
parser.add_option("-f", "--file", default=None)
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
print "verbose:", options.verbose
|
||||
print "file:", options.file
|
||||
parser.check_required("-f")
|
Loading…
Add table
Add a link
Reference in a new issue