Hi, I am wondering what would be the best way to return an iterator that has zero items.
I just noticed the following two are different: def f(): pass def g(): if 0: yield 0 pass for x in f(): print x Traceback (most recent call last): File "<string>", line 1, in <fragment> TypeError: 'NoneType' object is not iterable for x in g(): print x #loop exits without any errors Now the question here is this: def h(): if condition=true: #I would like to return an itereator with zero length else: for ...: yield x In other words, when certain condition is met, I want to yield nothing. How to do? Thanks, gz -- http://mail.python.org/mailman/listinfo/python-list