David> I'm with you on the desire to have a way to get a David> multipass-iterator-or-error in one swell foop. That says "I David> want to iterate over this thing without changing it". I still David> think that hasattr(iter(x), '__copy__') is a pretty clean way David> to do that, despite the fact that it potentially creates an David> iterator (which some people apparently view as too heavyweight David> as an introspection step). In particular, creating an iterator had better not be a destructive operation. David> However, I don't see any point in trying to define a protocol David> for every different possible iteration view of a thing. Dicts David> have keys, values, and items. Trees have breadth-first, David> depth-first, inorder, postorder, blah, blah, blah. There are David> just too many of these, and they're all different. I wasn't suggesting defining a protocol for every possible iteration view. I was raising the question of whether multi-pass iteration was likely to be a common enough operation that it is worth defining a protocol for it, while leaving the door open to defining protocols for others should it turn out to be desirable to do so.
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