Antoon Pardon <antoon.par...@rece.vub.ac.be>: > Op 23-06-16 om 11:53 schreef Marko Rauhamaa: > Maybe something like this: > > def empty(sq): > try: > iter(sq).next() > except StopIteration: > return False > except: > raise TypeError > else: > return True
That may or may not be as effective as a boolean check. The point is, Python has already declared that __bool__ is the canonical emptiness checker. You could even say that it's the principal purpose of the __bool__ method. Marko -- https://mail.python.org/mailman/listinfo/python-list