create boolean

Grant Edwards grante at
Mon Mar 9 00:48:32 CET 2009

On 2009-03-08, Rhodri James <rhodri at> wrote:
>>>>   b = (n is not None) and (n != [])
>>> The second comparison isn't actually necessary, since an
>>> empty list is True and a non-empty one False.
>>>    b = (n is not None) and n
>>> Putting the comparison in does make the code slightly less
>>> "magic", though, so it's not a bad idea to do it!
>> Putting in the second comparison in makes the code match the
>> stated requirement.  Otherwise you have to start making
>> assumptions about what n might be besides None or the empty
>> list.
> The OP stated that we *could* assume that n was None or a
> list, so I stand by what I said.

I didn't say that he hadn't authorized that assumption.  I just
said that the code does rely on such an assumption.  In my
experience, assumptions like that result broken code down the


More information about the Python-list mailing list