Test None for an object that does not implement ==

Paul Rudin paul.nospam at rudin.co.uk
Mon Dec 26 09:33:24 EST 2011


GZ <zyzhu2000 at gmail.com> writes:


> I run into a weird problem. I have a piece of code that looks like the
> following:
>
> f(...., a=None, c=None):
>     assert  (a==None)==(c==None)
>

There is only one 'None' - so use 'a is None' rather than 'a == None'.

(In common lisp there is a particular language construct that allows you
do determine whether an argument was passed in or was defaulted.)



More information about the Python-list mailing list