On Mon, 12 Jul 2010 20:22:39 -0700, Paul Rubin wrote: > Steven D'Aprano <steve-remove-t...@cybersource.com.au> writes: >> Writing the explicit tests: >> if bool(myInt): >> or even: >> if myInt <> 0: >> >> are firmly in the same category. The only difference is that it is more >> familiar and therefore comfortable to those who are used to languages >> that don't have Python's truth-testing rules. > > It's like list.append returning None. It helps catch errors.
How? >>> myInt = 'x' >>> if myInt <> 0: ... print "myInt is not zero, safe to divide" ... print 42/myInt ... myInt is not zero, safe to divide Traceback (most recent call last): File "<stdin>", line 3, in <module> TypeError: unsupported operand type(s) for /: 'int' and 'str' What error did this catch? -- Steven -- http://mail.python.org/mailman/listinfo/python-list