Wayne wrote:
Hi, I think I recall seeing this here, but I wanted to make sure I'm
correct.
Is the best way to test for an empty list just test for the truth value?
I.e.

mylist = [1,2,3]

while mylist:
   print mylist.pop()

Thanks,
Wayne

My take is simple: Use the above form if you *know* that mylist is in fact a list. If you don't know its type for sure (the name is a clue, but not conclusive ;-) ) then use a more specific test.

In your case, you know it's a list, or least something that supports pop(). So your form should be great.

DaveA
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to