Andrew Koenig wrote: > for i in myList.keys(): > > would be even better, because it allow the same usage for dict and > list. Of course that wouldn't generalize to other sequences that > support len. Hmm - time to propose a new builtin (can't remember this being proposed before, though I know we've discussed adding keys() to lists). keys(mapping) Returns an iterator of the keys of the mapping. For any sequence that implements __len__, returns an iterator of the integers 0..__len__. For any object that implements keys() or iterkeys(), returns the appropriate iterator. I would also suggest that __keys__ might be a useful magic method. There might be a use for values(mapping) as well, but I don't think it's as useful. 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