On 7/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > all(char in string.printable for char in testString) > > What is all? > Is that a 2.5 thing (I'm still on 2.4 here)
Yes, it's a 2.5 thing. All returns true if all of the elements of an iterable are true. According to the docs, it is the equivalent of the following: def all(iterable): for element in iterable: if not element: return False return True Using 'all' with a generator expression has the virtue of only needing to look at the string until it finds a single element that is false, and then returning. Not only that, it's concise (a single line) and quite readable (at least to me). -- Jerry _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor