On 23/06/2010 00:03, Greg Ewing wrote:
Benjamin Peterson wrote:

IIRC this was because UserDict tries to be a MutableMapping but abcs
require new style classes.

Are there any use cases for UserList and UserDict in new
code, now that list and dict can be subclassed?

Inheriting from list or dict isn't very useful as you to have to override *every* method to control behaviour.

(For example with the dict if you override __setitem__ then update and setdefault (etc) don't go through your new __setitem__ and if you override __getitem__ then pop and friends don't go through your new __getitem__.)

In 2.6+ you can of course use the collections.MutableMapping abc, but if you want to write cross-Python version code UserDict is still useful. If you want abc support then you are *already* on 2.6+ though I guess.

All the best,

Michael


If not, I don't think it would be a big problem if they
were left out of the ABC ecosystem. No worse than what
happens to any other existing user-defined class that
predates ABCs -- if people want them to inherit from
ABCs, they have to update their code. In this case, the
update would consist of changing subclasses to inherit
from list or dict instead.



--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of 
your employer, to release me from all obligations and waivers arising from any 
and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, 
clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and 
acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your 
employer, its partners, licensors, agents and assigns, in perpetuity, without 
prejudice to my ongoing rights and privileges. You further represent that you 
have the authority to release me from any BOGUS AGREEMENTS on behalf of your 
employer.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to