checking if a list is empty

harrismh777 harrismh777 at charter.net
Wed May 11 19:12:13 EDT 2011


harrismh777 wrote:
> Lists by themselves, empty or not, cannot have a 'truth' in an of
> themselves.

    ... forgot.,


    Based on Ian's comment a couple of days ago...

    if alist:


      ... is actually :


    if bool(alist):


    I think this is more than just semantics or silly argumentation. Its 
important to understand where the boolean truth is coming from...  my 
understanding 'now' is that the  list[] has no such boolean attribute, 
but is cast for the 'if' construct....


so...    if alist:    is   -->  if bool(alist):

and...   if not alist:    is also  -->  if not bool(alist):


    The 'alist[]' has no boolean attribute,   right??


kind regards,

m harris






More information about the Python-list mailing list