Message356273
Crash means 'python stopped erroneously without a traceback'.
Same exception in 3.8 and 3.9. Argparse uses None for a count of 0. I consider this a bug. If not changed, it should be documented. As argparse is, the example needs to recode None to 0. (Or, it could add '-v' to sys.argv.) With proper line wrapping, the result could be
import argparse
from getpass import getuser
parser = argparse.ArgumentParser(description='An argparse example.')
parser.add_argument('name', nargs='?', default=getuser(), # wrap
help='The name of someone to greet.')
parser.add_argument('--verbose', '-v', action='count')
args = parser.parse_args() # new
args.verbose = 0 if args.verbose is None else args.verbose
greeting = (["Hi", "Hello", "Greetings! its very nice to meet you"] #wrap
[args.verbose % 3])
print(f'{greeting}, {args.name}') |
|
Date |
User |
Action |
Args |
2019-11-08 23:29:23 | terry.reedy | set | recipients:
+ terry.reedy, docs@python, David Goldsmith |
2019-11-08 23:29:23 | terry.reedy | set | messageid: <1573255763.43.0.479045477329.issue38678@roundup.psfhosted.org> |
2019-11-08 23:29:23 | terry.reedy | link | issue38678 messages |
2019-11-08 23:29:22 | terry.reedy | create | |
|