Spot the bug: getoptquestion.py
Oscar
jornws0718 at xs4all.nl
Mon Jul 4 07:24:22 EDT 2016
Is this:
a) a bug in getopt.getopt
b) a bug in my code
c) a great way to keep me busy for a while
d) all of the above?
#!/usr/bin/python
from __future__ import print_function
from getopt import getopt, GetoptError
import sys
try:
opts, args = getopt(sys.argv[1:], 'b', ['bug '])
except GetoptError as err:
print('Caught:', repr(err))
else:
if opts:
for opt, arg in opts:
if opt in ('-b', '--bug'):
print ("Ceci n'est pas un bug!")
else:
#print ('Missed option: "{0}"'.format(opt))
print ('Missed option:', opt)
else:
print('Usage:', sys.argv[0],'-b|--bug')
--
[J|O|R] <- .signature.gz
More information about the Python-list
mailing list