Issue
Some programmers use sys.exit
, others use SystemExit
.
- What is the difference?
- When do I need to use
SystemExit
orsys.exit
inside a function?
Example:
ref = osgeo.ogr.Open(reference)
if ref is None:
raise SystemExit('Unable to open %s' % reference)
or:
ref = osgeo.ogr.Open(reference)
if ref is None:
print('Unable to open %s' % reference)
sys.exit(-1)
Solution
No practical difference, but there's another difference in your example code - print
goes to standard out, but the exception text goes to standard error (which is probably what you want).
Answered By - RichieHindle
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.