On 11/21/2014 03:24 AM, Raymond Hettinger wrote:
Also, the PEP motivation seemed somewhat weak. Instead of listing known bugs or real-world development difficulties, it seems to hinge almost entirely some "being surprised" that list comprehensions and generator expressions aren't the same in every regard (they aren't).
I believe the motivation is more along the lines of the difficulty and time wasted in debugging a malfunctioning program when a generator stops early because a StopIteration escaped instead of having some other exception raised.
This would be along the same lines as not allowing sum to work with str -- a more valid case, IMO, because the sum restriction is performance based, while this change would actually prevent breakage... or more accurately, put the breakage at the cause and make it much easier to fix.