Bjoern Schliessmann <[EMAIL PROTECTED]> writes: > Bruno Desthuilliers wrote: > > Shawn Milo a écrit : > > >> if recs.has_key(piid) is False: > > > > 'is' is the identity operator - practically, in CPython, it > > compares memory addresses. You *dont* want to use it here. > > It's recommended to use "is None"; why not "is False"? Are there > multiple False instances or is False generated somehow?
I'd recommend against using "is False" simply because it's more confusing. This is better:: if not recs.has_key(piid): # [1] Moreover, any 'if' statement expects a boolean expression *anyway*, so there's no point testing for identity against False. Otherwise, the following would be just as reasonable:: if (recs.has_key(piid) is False) is True: Or perhaps: if (((((recs.has_key(piid) is False) is True) is False) is False) is True): [1]: yes, this is even better written as 'if not piid in recs', but that's beside the point for this discussion. -- \ "To be is to do" -- Plato | `\ "To do is to be" -- Aristotle | _o__) "Do be do be do" -- Sinatra | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list