Re: --help option: sys.exit or return?
Miguel A Figueroa-Villanneva <[email protected]> Wed, 20 Oct 2004 13:00:25 -0400 (EDT)
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <Pine.GSO.4.58.0410201236570.10690@scully> |
I'm sorry for all the fuzz generated about this. My argument was generated
mostly by naiveness in Python programming since I'm not experienced with
it. And as Gerg explained the "aiee, dumped out..." was exactly what
bothered me...
A solution was pointed out by Greg that comepletely satisfies my learning
curiosity, doesn't require "ruining" a good module (optik, optparse), and
involves little effort in my part:
def main(argv=[__name__]):
...
try: (options, args) = parser.parse_args(argv[1:])
except SystemExit: return("Caught Exit Exception")
...
if __name__ == "__main__": sys.exit(main(sys.argv))
I only lay out the code and clarify the idea for those who might be
following the thread and are as lost as me... It is not a "nice" solution,
but remember that this is just for using the interpreter to test out and
learn while you develop stuff. I would expect to remove the try,except and
let the program exit gracefully after developement.
Thanks for your comments Greg. And I agree that there is nothing to
discuss regarding changing optik design because of this issue.
--Miguel
========================================================================
The one who teaches is the giver of eyes. - Tamil (Asian Indian) Proverb
========================================================================
-------------------------------------------------------
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