Re: sys.exit versus raise SystemExit



Will McGugan <will@xxxxxxxxxxxxxxxxxxxxx> wrote:

wittempj@xxxxxxxxxxx wrote:

sys.exit() raises a SystemExit, see
http://docs.python.org/lib/module-sys.html

Oh I know. I was just wondering if there was some sort of subtle 'best
practice' recommendation that I wasnt aware of for using sys.exit over
raising the exception manually. In the same way that 'open' is prefered
over 'file', even though they appear to do the same thing.

'open' is preferred when you are opening a file, 'file' is preferred when
it is the type you want. That way you leave open the option to intercept
the 'open' action without interfering with tests against the type.

I guess in a similar way you should prefer the overridable sys.exit()
function rather than using the exception directly.
.



Relevant Pages

  • Re: sys.exit versus raise SystemExit
    ... I was just wondering if there was some sort of subtle 'best practice' recommendation that I wasnt aware of for using sys.exit over raising the exception manually. ...
    (comp.lang.python)
  • Re: Viewing a .wmv in OS9?
    ... Tankers), is a Yacht Master so well traveled, was on ... intelligent people struggle with computers (of any sort) even if they have ... assisted in the project of building a kit car. ... driving practice and she questioned "which way" when it was ...
    (uk.comp.sys.mac)
  • XP
    ... I bought the Dan Balter "Exam Cram" book, ... and got my hands on practice tests from ... My recommendation is that you practice on an XP Pro PC ... along with a Win 2000 server if possible. ...
    (microsoft.public.cert.exam.mcse)
  • Re: Postal Strike - The Issues
    ... employee expects to be able to go straight home. ... There would be no option to refuse OT when inconvenient or not ... postie who is getting paid to sort cannot refuse to sort simply because he ... Additional meal and grace breaks as custom and practice ...
    (uk.legal)
  • Re: what the hell happened to my rainbow?
    ... this kindly sort of patronizing "help". ... and spiritual practice, but what i do on this level is mine and i ... ask your friend then, soon and often, ... quotes from chekov!(i'm joking, chekov is fine) but trust that your ...
    (alt.gathering.rainbow)