4 ms·
Couldn't the runtime just allocate a specific Python object representing the case where the iterator is complete? Make that object implementation-specific, hide
by fouric 5y ago
Couldn't the runtime just allocate a specific Python object representing the case where the iterator is complete? Make that object implementation-specific, hide it as best as you can, write documentation stating that users should not use this value directly, and if they do - they voided the warranty, and should expect evil to befall them. (ultimately, you can't prevent the user from doing really dumb things e.g. editing the Python binary directly)
- dragonwriter 5y agoYou do that with one thing, okay, maybe it works. You do that with two or more of the protocols that Python has that use return values for return values ans exceptions for flow control signals and...you make it a lot harder to work with them, especially in conjunction.
- fouric 5y agoCan you give an example of this? I can't think of any myself - generators also raise a StopIteration exception, for instance, so they could use the same value.