whats new in 2.2 (was A modest indentation proposal)

Laura Creighton lac at strakt.com
Mon Dec 3 18:11:18 EST 2001


Here is my current decorator pattern:

class Decorator:
    """An abstract Decorator class based on one posted to comp.lang.python
    by Rainer Deyke.
    """
    def __init__(self, decorated):
        self._decorated = decorated
    # add some data attributes you want
    def __getattr__(self, name):
        return getattr(self._decorated, name)
    def __call__(self, *args, **kwargs):
        self._decorated(*args, **kwargs)
    # Override other operators too

This relies on the fact that my __getattr__ will not get called if
python already finds the attribute.  What am I supposed to do in 2.2
with not classic classes, if this is the exact behaviour I want?

Laura Creighton





More information about the Python-list mailing list