Shriphani wrote: > If I have a function that loops over a few elements and is expected to > throw out a few tuples as the output, then what should I be using in > place of return ?
Use a generator and have it /yield/ rather than /return/ results: >>> def f(items): ... for item in items: ... yield item.isdigit(), item.isupper() ... >>> for result in f("AAA bbb 111".split()): ... print result ... (False, True) (False, False) (True, False) This is a very memory-efficient approach, particularly if the input items are created on the fly, e. g. read from a file one at a time. Peter -- http://mail.python.org/mailman/listinfo/python-list