UserDict's has_key() and get() should use __getitem__()
hamish_lawson at yahoo.co.uk
Wed Apr 5 14:24:23 CEST 2000
Michael Hudson wrote:
>Hmm. These are likely to be rather less efficient than the
>current implementation, so you want to penalise those who use
>UserDict for the sake of those who don't subclass it
>thoroughly - do you really want to do this?
I grant that my proposal is a bit less efficient, but I see that
as part of the cost for the proper abstraction. Given that
UserDict exists primarily to be subclassed, and usually for the
purpose of providing new definitions of setting and getting
items, I do think that UserDict should be implemented in such a
way as not to require those methods which are conceptually
dependent to be redefined in the derived class. If they are
conceptually dependent they should be made so in the code.
>Let's face it, you're unlikely to make this mistake again.
Except that I think subclassers should be able to make
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
More information about the Python-list