On Wed, 19 Jul 2000, Barry A. Warsaw wrote:
I've been thinking a little bit about the other generators, especially irange(). I wonder if we shouldn't just be putting zip() and friends in their own Python module and not make them builtins?
I'd say put both zip() and irange() in builtins. They're useful enough. (Ideally range(), zip(), and irange() would all make generators one day, and xrange() could be deprecated.) I would prefer zip() and irange() to make generators now -- because this means you could *pass* them generators, and they wouldn't force their arguments to enumerate everything first! For example, make readlines() a generator too and you've got for lnum, line in irange(file.readlines()): print "%5d: %s" % (lnum, line), How pretty is that? There's no issue with using generators in place of lists, as far as i can tell, since (as has already been suggested) you just turn the generator into a real list if somebody calls one of the methods on it or uses it where a tuple is expected. -- ?!ng