[Python-Dev] class dict of subtyped types

Guido van Rossum guido@python.org
Mon, 29 Oct 2001 15:12:19 -0500


> > The dict-proxy type is intended to provide a read-only proxy, so the
> > dict-proxy is consciously lacking the update, clear, popitem and
> > setdefault methods.  It also seems to be missing the comparison
> > operations; that's an oversight.
> > 
> But adding attributes to the INT class above after creation
> is allowed, I hope? At least it currently works.

Yes, but you have to use the attribute notation:

    INT.foo = ...

this is trapped so that certain magic happens automatically when you
set attributes that override operators, e.g.

    INT.__add__ = lambda ...

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