Lie Ryan wrote:
Fencer wrote:
The literal translation of that would be:
if n is not None and n != []:
    b = True
else:
    b = False
it is a bit verbose, so one might want to find something shorter
b = True if n is not None and n != [] else False
I always feel if and in-line if to be easier and more readable than short-circuited operations.

How about:
   b = None is not n != []

It is amazing to think about how rarely we consider is / is not as
a comparison operator.  Also, and more reasonably, we often don't
consider "chaining" comparisons that are intransitive.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to