sys.exit(1) vs raise SystemExit vs raise
Random832
random832 at fastmail.com
Tue Apr 12 10:16:41 EDT 2016
On Tue, Apr 12, 2016, at 10:12, Ganesh Pal wrote:
> >
> >
> > No; raise SystemExit is equivalent to sys.exit(0); you would need raise
> > SystemExit(1) to return 1.
> >
>
> Thanks will replace SystemExit with SystemExit(1) .
>
>
>
> > Why do you want to do this, though? What do you think you gain from it?
> >
>
> Iam trying to have a single exit point for many functions: example
> create_logdir() , create_dataset() and unittest.main() will bubble out
> an
> exception using raise
How is this not accomplished by using sys.exit(1) in the except block?
> I would want to terminate the program when this happens .
>
> Do you see any problem if *raise *SystemExit(1) is used in the except
> block ?
I still don't understand what you think you gain from this.
More information about the Python-list
mailing list