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/2014-November/137022.html below:

Change StopIteration handling inside generators

[Python-Dev] PEP 479: Change StopIteration handling inside generators [Python-Dev] PEP 479: Change StopIteration handling inside generatorsEthan Furman ethan at stoneleaf.us
Fri Nov 21 17:31:41 CET 2014
On 11/21/2014 05:47 AM, Raymond Hettinger wrote:
> 
> Also, the proposal breaks a reasonably useful pattern of calling next(subiterator)
> inside a generator and letting the generator terminate when the data stream  ends.
>
> Here is an example that I have taught for years:
> 
>     def [...]
>         it1 = iter(iterable1)
>         it2 = iter(iterable2)
>         while True:
>             v1 = next(it1)
>             v2 = next(it2)
>             yield v1, v2

Stepping back a little and looking at this code, sans header, let's consider the possible desired behaviors:

  - have an exact match-up between the two iterators, error otherwise
  - stop when one is exhausted
  - pad shorter one to longer one

Two of those three possible options are going to require dealing with the StopIteration that shouldn't escape -- is the
trade of keeping one option short and simple worth the pain caused by the error-at-a-distance bugs caused when a
StopIteration does escape that shouldn't have?

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-dev/attachments/20141121/086d994c/attachment.sig>
More information about the Python-Dev mailing list

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