[Python-Dev] PEP 276 (simple iterator for ints) (original) (raw)
Delaney, Timothy C (Timothy) tdelaney at avaya.com
Mon Jul 5 01:31:10 CEST 2004
- Previous message: [Python-Dev] VC 7.1 maintenance? [getting OT]
- Next message: [Python-Dev] Undo indenting of macros in Include/pyport.h?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] VC 7.1 maintenance? [getting OT]
- Next message: [Python-Dev] Undo indenting of macros in Include/pyport.h?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]