[Python-ideas] Idea for the mapping API

Raymond Hettinger python at rcn.com
Sun Feb 10 02:22:43 CET 2008


Perhaps, the dict() constructor should accept any object with a __dict__ method.

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.


Raymond


More information about the Python-ideas mailing list