Author tanqazx
Recipients bethard, docs@python, eric.araujo, jayt, tanqazx
Date 2010-12-16.09:04:50
SpamBayes Score 8.5466e-08
Marked as misclassified No
Message-id <>
I am also trying to use argparse interactively, but in this case by combining it with the cmd module. So I'm doing something like below:

class MyCmd(cmd.Cmd):

    parser = argparse.ArgumentParser(prog='addobject')

    def do_addobject(self, line):
        args = MyCmd.parser.parse_args(line.split())
        newobject = object(args.attribute1, args.attribute2, args.attribute3)

I'm faced with the same problem that when given invalid input, parse_args exits the program completely, instead of exiting just to the Cmd shell. 

I have the feeling that this use case is sufficiently common such that it would be good if people did not have to override the exit method themselves, and instead an alternative to parse_args was provided that only raises exceptions for the surrounding code to handle rather than exiting the program entirely.
Date User Action Args
2010-12-16 09:04:51tanqazxsetrecipients: + tanqazx, bethard, eric.araujo, docs@python, jayt
2010-12-16 09:04:51tanqazxsetmessageid: <>
2010-12-16 09:04:50tanqazxlinkissue9938 messages
2010-12-16 09:04:50tanqazxcreate