A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/026289.html below:

[Python-Dev] Single- vs. Multi-pass iterability

[Python-Dev] Single- vs. Multi-pass iterability [Python-Dev] Single- vs. Multi-pass iterabilityAndrew Koenig ark@research.att.com
Thu, 11 Jul 2002 12:16:15 -0400 (EDT)
David> Why bother with __multiter__? If you can distinguish a multiple
David> iterator by the presence of __copy__, You can always do
David> hasattr(x.__iter__(),"__copy__") to find out whether something
David> is multi-iteratable.

Because explicit is better than implicit :-)

More seriously, I can imagine distinguishing a multiple iterator by
the presence of __copy__, but I can't imagine using the presence of
__copy__ to determine whether a *container* supports multiple
iteration.  For example, there surely exist containers today that
support __copy__ but whose __iter__ methods yield iterators that do
not themselves support __copy__.

Another reason is that I can imagine this idea extended to encompass,
say, ambidextrous iterators that support prev() as well as next(),
and I would want to use __ambiter__ as a marker for those rather
than having to create an iterator and see if it has prev().




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4