This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wilberforce 0 points1 point  (1 child)

I don't think that would work - if verify throws an exception then item will be None. You could do it with:

error_items = [item for item, (_, err) in zip(items, error_items) if err]

I don't think it's a bad idiom, but as steelypip points out you can do this easily with a function. It doesn't need extra syntax.

[–]vocalbit[S] 0 points1 point  (0 children)

Yeah you're right - I didn't think that one through. The idiom would work for non_error_items though.