[issue39333] argparse should offer an alternative to SystemExit in case a parse fails

2020-01-14 Thread Jack Orenstein


Jack Orenstein  added the comment:

Yes! I didn't know about that method, thank you.

--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39333] argparse should offer an alternative to SystemExit in case a parse fails

2020-01-14 Thread Eric V. Smith


Eric V. Smith  added the comment:

Maybe argparse could raise an exception derived from SystemExit, then you could 
catch that.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39333] argparse should offer an alternative to SystemExit in case a parse fails

2020-01-14 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Does overriding exit help here?

https://docs.python.org/3.8/library/argparse.html#argparse.ArgumentParser.exit

--
nosy: +paul.j3, xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39333] argparse should offer an alternative to SystemExit in case a parse fails

2020-01-14 Thread Zachary Ware


Change by Zachary Ware :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39333] argparse should offer an alternative to SystemExit in case a parse fails

2020-01-14 Thread Jack Orenstein


New submission from Jack Orenstein :

If parse_args fails, SystemExit is raised, carrying an exit code of 2, and the 
help message is printed. For an embedded usage of argparse, this behavior is 
undesirable.

I am writing an interactive console application, using argparse to parse input. 
When a parse fails, I would like to print an error message and continue, not 
terminate the program. Currently, I need to catch SystemExit to be able to do 
this, which has obvious problems, (e.g., what if something other that argparse 
is causing the exit?)

I'd like to see some way to specify alternative behavior, e.g. raise an 
exception of a given type.

--
components: Library (Lib)
messages: 359991
nosy: geophile
priority: normal
severity: normal
status: open
title: argparse should offer an alternative to SystemExit in case a parse fails
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com