[issue9523] Improve dbm modules

Éric Araujo report at bugs.python.org
Fri Feb 4 01:52:19 CET 2011


Éric Araujo <merwok at netwok.org> added the comment:

Thank you for working on a patch, especially with such comprehensive tests.

> The object returned by :func:`.open` supports the same basic functionality as
> -dictionaries
> +:mod:`collection`.MutableMapping

The previous text was okay, I wouldn’t have changed it.

>     def items(self):
>+        return set([(key, self[key]) for key in self._index.keys()])
I don’t know if you should use a plain set or a collections.ItemsView here.  In dict objects, KeysView and ValuesView are set-like objects with added behavior, for example they yield their elements in the same order.  Raymond, can you comment?

Style remarks: you can iter without calling _index.keys(); you can avoid the intermediary list (IOW, remove enclosing [ and ]).

In the tests, you can use specialized methods like assertIn and assertIsNone, they remove some boilerplate and can give better error output.

I can’t review the C code. :)

----------
nosy: +rhettinger
versions: +Python 3.3 -Python 3.2

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


More information about the Python-bugs-list mailing list