Re: --help option: sys.exit or return?

Greg Ward <[email protected]> Tue, 19 Oct 2004 22:35:05 -0400
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
On 20 October 2004, [email protected] said:
> I don't understand the OP's problem or what the use case is.
[...]
> If you want to call your foofunc from within the interpreter, you just type that in yourself, 
> don't you? Why bother going through optik?

I assume that his point was that for learning/experimenting/playing
around, an interactive interpreter session is ideal.  I do that all the
time when learning a new module.  I don't do that with Optik, since I
know its capabilities and syntax pretty well.  ;-)  But I don't like
this:

  $ python            # hmmm, this optik thing looks neat, let's play...
  [...]
  >>> from optik import *
  >>> parser = OptionParser()
  >>> parser.parse_args(["--help"])
  usage:  [options]

  options:
    -h, --help  show this help message and exit
  $                    # aiee, dumped out of Python and back to the shell!

I had (very) slight misgivings about making Optik sys.exit() when it
does, and now I understand why.  Well, I still don't regret it --
although it violates a basic rule of writing libraries, this is a
library for "doing the right thing" in command-line processing, and that
means exit in certain ways at certain times.

        Greg
-- 
Greg Ward <[email protected]>                         http://www.gerg.ca/
Never put off till tomorrow what you can put off till the day after tomorrow.


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl