[Python-ideas] Idea for the mapping API

Guido van Rossum guido at python.org
Sun Feb 10 03:34:39 CET 2008


On Feb 9, 2008 5:22 PM, Raymond Hettinger <python at rcn.com> wrote:
> Perhaps, the dict() constructor should accept any object with a __dict__ method.

Won't that interfere with the existing __dict__ *attribute* of most
objects (e.g. modules)?

> The principle is that almost any object that has key and value pairs (named tuples for example) should be readily convertable to and
> from a dictionary.  The current, non-uniform alternative is for the object to provide an asdict() method and for the user to call it
> directly.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-ideas mailing list