Author jayt
Recipients docs@python, jayt
Date 2010-09-24.14:31:28
SpamBayes Score 3.35133e-09
Marked as misclassified No
Message-id <>
I want to create a custom interactive shell where I continually do 
parse_args.  Like the following: 
parser = argparse.ArgumentParser() 
command = raw_input() 
  args = parser.parse_args(shlex.split(command)) 
  # Do some magic stuff 
  command = raw_input() 
The problem is that if I give it invalid input, it errors and exits 
with a help message.

I learned from argparse-users group that you can override the exit method like the following:

class MyParser(ArgumentParser): 
  def exit(self, status=0, message=None): 
    # do whatever you want here 

I would be nice to have this usage documented perhaps along with best practices for doing help messages in this scenario.
Date User Action Args
2010-09-24 14:31:30jaytsetrecipients: + jayt, docs@python
2010-09-24 14:31:30jaytsetmessageid: <>
2010-09-24 14:31:29jaytlinkissue9938 messages
2010-09-24 14:31:28jaytcreate