[EMAIL PROTECTED] a écrit : > On Apr 13, 5:14 pm, "SamG" <[EMAIL PROTECTED]> wrote: >> import sys >> try: >> s=1 >> if s==1: >> sys.exit(0) >> else: >> sys.exit(1) >> except SystemExit,s: >> if (s==0): >> print s >> else: >> print "Hello" >> >> How come i always end up getting the "Hello" printed on the screen as >> logically i should a '0' printed? > > > if you put a debug print statement, eg > > ... > except SystemExit,s: > print "s in exception " , s, type(s) > if (s==0): > .... > > you will notice 's' is an "instance".
Not with Python 2.5.x (exceptions are now new-style classes too). > so when it reaches the if > (s==0), which you are comparing with a number, Actually, with an instance of class int. Everything in Python is an object. But the comparison will fail, indeed. -- http://mail.python.org/mailman/listinfo/python-list