Greg Ewing wrote:
Steven D'Aprano wrote:
With iterators being such a fundamental part of Python these days,
perhaps one day we'll see the functions in the itertools module become
iterator methods
I hope not. The set of potential functions that operate
on iterators is open-ended, and there's no reason to
single out a particular subset and make them methods.
I've occasionally experimented with the idea of a 'FlexibleIterator'
class that accepted an arbitrary iterable in it's constructor and then
used itertools internally to provide native support for concatenation
(via itertools.chain) and slicing (via itertools.islice), but have never
been able to come up with anything which didn't lend itself to
fundamental misunderstanding of what it was doing.
I've come to the conclusion that there are some aspects of dealing with
arbitrary iterators where trying to make it look 'pretty' starts to hide
things that the programmer really needs to be aware of in order to
reason correctly about the program.
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com