On Fri, 06 May 2011 14:57:21 -0700, scattered wrote:

> is there any problem with
> 
> (3) if li == []:
> 
> ?
> 
> Seems to work when I test it and seems to clearly test what you are
> trying to test. The only problem might be if in some contexts == has the
> semantics of checking for object identity.

Yes, if li == [] works too. But how do you know li is a list and not some 
other sequence type?

The advantage of the "if x" test is that it is independent of the type of 
x.

-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to