a newbie OptParse thread. Is there a way to catch all?

googleboy mynews44 at yahoo.com
Thu Jul 22 20:50:20 CEST 2004


Hiya everyone.  

I have now implemented my newbie script with optparse and it works
great, but in the final QA phase I found that I could put any sort of
stuff on the command line anywhere and the script would simply ignore
it,  rather than breaking with an error.  IE,  after I define -h,  -V,
-s, -t, -w, -c and their relevent lnog versions as valid parameters, 
I call the program thus:

$>./my_script -s 3 -c 88 asdsa  -w99 -t14
OK. The script worked great!


Is there some way of implementing a catchall type of add_option that
would run a callback to some sort of predefined error function? 
Something that could catch that "asdsa" stuff?

Or is there a better way (more pythonish!) to do it?

Thanks for your attention!

googleboy



More information about the Python-list mailing list