[Python-ideas] sentinel_exception argument to `iter`

Yury Selivanov yselivanov.ml at gmail.com
Fri Feb 7 04:01:41 CET 2014


On 2/6/2014, 9:36 PM, Terry Reedy wrote:
> I think this would be a great idea if simplified to reuse the current 
> parameter. It can work in Python because exceptions are objects like 
> anything else and can be passed as arguments. No new parameter is needed.
What will the following code print:

    d = deque((42, IndexError, 'spam'))
    print(list(iter(d.popleft, IndexError)))

?

Yury


More information about the Python-ideas mailing list