> From: David Abrahams [mailto:david.abrahams@rcn.com] > > One other possibility: if x.__iter__() is x, it's a > single-pass sequence. I > realize this involves actually invoking the __iter__ method > and conjuring > up a new iterator, but that's generally a lightweight operation... Definitely not reliable - it will fail for a file object ... (even with the changes currently going in). What would be more reliable (but still not infallible) would be: if iter(x) == iter(x): # this is *definitely* a single-pass iterable All iterators are by definition single-pass iterables, and with the changes being made to the file object, the above code would work for all builtin iterable types as well. Tim Delaney
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4