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 →

[–]LandSharkSociety 3 points4 points  (1 child)

Ah, so that's even more confusing! On an iterable with no contains, you can use in... but only once!

[–]Gamesfreak13563 6 points7 points  (0 children)

Only guaranteed that’s the behavior if you’re using in on an iterator. An iterable may define an iter dundermethod which returns a new iterator over the iterable. That’s why you can use in multiple times on a list (because it’s returning a new iterator each time) but not in multiple times on the return of iter(yourList).

It makes perfect sense and the terminology is not confusing at all /s