A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-August/028492.html below:

[Python-Dev] Proposed Mixins for Wide Interfaces

[Python-Dev] Proposed Mixins for Wide InterfacesRaymond Hettinger python@rcn.com
Sat, 31 Aug 2002 12:44:06 -0400
How about adding some mixins to simplify the
implementation of some of the fatter interfaces?

class CompareMixin:
    """
    Given an __eq__ method in a subclass, adds a __ne__ method
    Given __eq__ and __lt__, adds !=, <=, >, >=.
    """

class MappingMixin:
    """
    Given __setitem__, __getitem__,  and keys,
    implements values, items, update, get, setdefault, len,
    iterkeys, iteritems, itervalues, has_key, and __contains__.

    If __delitem__ is also supplied, implements clear, pop,
    and popitem.

    Takes advantage of __iter__ if supplied (recommended).
    
    Takes advantage of __contains__ or has_key if supplied
    (recommended).
    """

The idea is to make it easier to implement these interfaces.
Also, if the interfaces get expanded, the clients automatically
updated.  


Raymond Hettinger





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4