Catch-all proposal based on proxies
Brendan Eich
brendan at mozilla.com
Thu Dec 10 13:30:55 PST 2009
On Dec 10, 2009, at 12:56 PM, Mike Samuel wrote:
>> Generators compose in some ways though the syntax can be awkward:
>> def zip(a, b):
>> for a_el in a:
>> yield (a_el, b.next())
>> try:
>> b.next()
>> except StopIteration:
>> pass
>> except:
>> raise AssertionError('%r not exhausted', b)
>
> Sorry, zip should probably just read
> def zip(a, b):
> for a_el in a:
> yield (a_el, b.next())
> b.next()
Right -- it really is quite rare to have to catch StopIteration. If
you feel the need, something else may be going on that needs
addressing at a higher level.
/be
More information about the es-discuss
mailing list