On 12/24/2011 11:09 PM, GZ wrote:
Hi,
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)
<...>
At first glance this looked like it should be a simple boolean "and", but then I realized that
when a and c are both unequal to None, the result would also be True. This implies the logical
approach would be exclusive-or (^). Try this expression:
not ((a==None) ^ (c==None))
OTOH, if what you really want is simply to check that both are None (my first impression), then
it's simply:
(a==None) and (c==None)
Most of the replies you're getting here seem unnecessarily complicated.
Thanks,
gz
-=- Larry -=-
--
http://mail.python.org/mailman/listinfo/python-list