A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-October/092522.html below:

[Python-Dev] PEP 389: argparse - new command line parsing module

[Python-Dev] PEP 389: argparse - new command line parsing module [Python-Dev] PEP 389: argparse - new command line parsing moduleYuvgoog Greenle ubershmekel at gmail.com
Sat Oct 3 18:38:31 CEST 2009
On Sat, Oct 3, 2009 at 7:21 PM, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> [snip...]
> Why not just catch SystemExit? If you want a custom exception the overriding .exit() should be sufficient.
> I'd be much more interested in Guido's suggestion of auto-generated custom help messages for sub-commands.

Check it out:

def ParseAndRun():
    crazy_external_function_that_might_exit()

    # Argparse blah blah
    parser.parse_args()

if __name__ == "__main__":
    try:
        ParseAndRun()
    except SystemExit:
        # was it crazy_external_function_that_might_exit or an argparse error?


I know this might come through as bike shedding but it's just
customary python that every module have it's own exception types as to
not mix them up with others.

--yuv
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4