[Tutor] exit message
Amit Saha
amitsaha.in at gmail.com
Mon May 6 06:27:14 CEST 2013
On Mon, May 6, 2013 at 2:24 PM, Jim Mooney <cybervigilante at gmail.com> wrote:
> I've noticed that if you exit() a program you always get a traceback message:
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> exit('what now?')
> File "C:\Python33\lib\site.py", line 380, in __call__
> raise SystemExit(code)
>
> What if you just want to exit for some normal reason and don't want
> the message? Or is a program always supposed to end in some normal way
> without an exit. Or is there a different, more graceful way to end a
> program when you want?
Something like this?
>> import sys
>>> while 1:
... sys.exit('Exiting from Infinite Loop')
...
Exiting from Infinite Loop
-Amit.
--
http://echorand.me
More information about the Tutor
mailing list