From: David Abrahams [mailto:email@example.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.