Dick Moores wrote: > At 11:44 AM 7/13/2008, Steve Willoughby wrote: >> Dick Moores wrote: >>> Yes! A rule, not logic. I'm not contradicting Kent, just helping >>> myself understand. First the rule, then logic in the application of >>> the rule. And I assume the rule is there in Python because it makes >>> things work better. >> >> Yes, so a statement like "if foo:" becomes an idiom for "if the >> collection foo has stuff in it:" which is handy whether foo is a text >> string or a list of objects. > > Yes, I've been using that, a bit uneasily. > > One question about the data I listed. Why is bool(set([])) false, > whereas bool([[]]) is true?
In the first example you're passing an empty list to the set constructor, and getting back an empty set object. In the second, you're providing a list with one element, which just so happens to be an empty list, but it doesn't matter -- since the outer list is not empty. Perhaps a better comparison would be bool(list([])) => False. HTH, Marty _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor