[Patches] UserDict/UserList: raise TypeError when trying to set attrs

Greg Ward gward@cnri.reston.va.us
Mon, 14 Feb 2000 15:16:18 -0500


On 14 February 2000, Gerrit Holl said:
> Moshe Zadka wrote on 950553454:
> > I'm certain I'm against this patch: it would make deriving from UserDict
> > (e.g.) that much harder, by needing to override __setattr__ for any
> > new attributes you'd want to add.
> 
> I don't know why one would do that but... OK, thanks for answering!

Because the whole *point* of UserList and UserDict is to subclass them.
If all you need is the functionality provided by UserList or UserDict,
then you should just be using a raw list or dictionary.  If nothing
else, it's faster.

> Hmm, if subclassing standard objects will eventually be implemented, I
> wonder how this would be done...

I believe the reason that UserList and UserDict exist at all is because
you *can't* derive from standard Python types like "list" and
"dictionary".  This is the infamous "type/class dichotomy", and I think
the best place to talk about that is on the types-sig.  (I.e. it's not
going to be fixed with a 20-line patch to patches@python.org.)

        Greg