On Tue, Oct 6, 2009 at 9:04 AM, Wayne <sri...@gmail.com> wrote: > If it's checking the returncode against a value, Vern makes a good point: > if returncode != 0 makes a whole lot more sense than "if not returncode == > 0" > Though when dealing with an integer return code, doesn't it make more sense > to use the "is" operator? > if returncode is 0: > #do something > if returncode is not 0: > #do something
No! Equality and identity are different. CPython does cache small integers but that is an implementation detail that you should not rely on. For large values you cannot presume that equal numbers are also identical. For example: In [1]: a=1000000000 In [2]: b=1000000000 In [3]: a==b Out[3]: True In [4]: a is b Out[4]: False Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor