On 2009-03-06, Fencer <no.s...@plz.ok> wrote: > Hi, I need a boolean b to be true if the variable n is not > None and not an empty list, otherwise b should be false.
> I ended up with: > b = n is not None and not not n I'd do it like this: b = (n is not None) and (n != []) Your code doesn't meet your stated requirement. Your code incorrectly evaluates to False if n is any of the following: (,) {} False 0 0.0 Your stated requirement is for b to be True for all those cases. > which seems to work > > but is that normally how you would do it? > > It can be assumed that n is always None or a list that might > be empty Well then, that's different. :) Still, I'd do it my way. I don't like assumptions. -- Grant Edwards grante Yow! If Robert Di Niro at assassinates Walter Slezak, visi.com will Jodie Foster marry Bonzo?? -- http://mail.python.org/mailman/listinfo/python-list