[issue5736] Add the iterator protocol to dbm modules

Akira Kitada report at bugs.python.org
Sat Apr 11 16:11:29 CEST 2009


Akira Kitada <akitada at gmail.com> added the comment:

Attached is a patch that adds the iterator protocol.
Now it can be interated through like:

>>> for k in d: print k, d[k]
... 
key1 vale1
key3 vale3
key0 vale0
key2 vale2
key4 vale4

The problem is there is no way to get the internal pointer back to the
start. So Once it reached to the end, you are done.

>>> for k in d: print k, d[k]
...

The solution to this would be:
- Add a method to get the pointer back to the start
  (with {first,next}key API)
- Add a method that returns a generator

----------
keywords: +patch
Added file: http://bugs.python.org/file13673/issue5736.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5736>
_______________________________________


More information about the Python-bugs-list mailing list