[Python-ideas] possible attribute-oriented class

Jan Kaliszewski zuo at chopin.edu.pl
Fri Sep 4 22:37:15 CEST 2009

04-09-2009 Ken Newton <krnewton at gmail.com> wrote:

> I like this version very much. I'm ready to put this into practice to see
> how it works in practice.

Not only you (Ken) and me. :-) It appears that the idea is quite old. Nick
Coghlan replied at python-ideas at python.org:

> Jan Kaliszewski wrote:
>> What do you think about it?
> It reminds me a bit of the old (short-lived) namespaces module:
> http://web.archive.org/web/20060216094030/http://namespace.python-hosting.com/
> Steven's draft PEP on the topic is still available in the python-list
> archives:
> http://mail.python.org/pipermail/python-list/2005-February/307235.html
> The problem we found with it was that the basic solutions (empty class
> and now named_tuple) were good enough that it wasn't worth the hassle
> involved in grabbing an extra library for it.

Named tuples (which indeed are really very nice) are read-only, but the
approach they represent could (and IMHO should) be extended to some kind
of mutable objects.

The old discussion, the above link points to, shows that such a
dot-accessible dict-like class is something that many people need and
repeatedly implemet it (more or less perfectly) for themselves.

Maybe that past proposition (to add a separate namespace module which
a number types for viewing, chaining and so on) was too sophisticated?

Most common use cases could be covered with one attr-dict-like type,
that could be placed in collections module (or even, in time, as
a built-in factory function, together with namedtuple?).


More information about the Python-ideas mailing list