Author terry.reedy
Recipients David Goldsmith, docs@python, terry.reedy
Date 2019-11-08.23:29:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1573255763.43.0.479045477329.issue38678@roundup.psfhosted.org>
In-reply-to
Content
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}')
History
Date User Action Args
2019-11-08 23:29:23terry.reedysetrecipients: + terry.reedy, docs@python, David Goldsmith
2019-11-08 23:29:23terry.reedysetmessageid: <1573255763.43.0.479045477329.issue38678@roundup.psfhosted.org>
2019-11-08 23:29:23terry.reedylinkissue38678 messages
2019-11-08 23:29:22terry.reedycreate