On Wed, Jan 11, 2012 at 09:49:58AM +0530, Noufal Ibrahim wrote:

> > It is not clear what you want from your description.  To check if a
> > list is empty, see if len( list ) is zero.
> 
> You don't want to do that. Your "list" might be a generator (unless you
> check for type which is a bad idea anyway) and "len"ing that will
> consume it which might be a potentially expensive operation. 

While the explaination on __nonzero__ is useful out of this context,
how can list be a generator? I am assuming that none are confusing the
terminologies.

In practical cases for testing boolean in lists, just use the list as
the test. Empty list is false.

-- 
Senthil

_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to