[Python-Dev] PEP 318 - generality of list; restrictions on elements

Bernhard Herzog bh at intevation.de
Tue Mar 9 05:01:21 EST 2004


Greg Ewing <greg at cosc.canterbury.ac.nz> writes:

> To allow for dynamic insertion of a sequence of wrappers, I can
> think of two possibilities:
>
> (A) Allow a list or tuple of further items to be used as an item.
>
> (B) Allow a '*' before an item to mean that the item is to
> be treated as a sequence of items to be iterated over.

(C) Define a function that takes a sequence of decorators and returns a
decorator that applies all decorators.

E.g.

def decorators(decs):
    def apply_decorators(f):
        for d in decs:
            f = d(f)
        return f
    return apply_decorators

def f(x) [decorators([foo, bar])]:
    pass


This scheme would have the advantage that it doesn't require any
additional syntax.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/



More information about the Python-Dev mailing list