A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-August/047534.html below:

[Python-Dev] Re: Re: Call for defense of @decorators

[Python-Dev] Re: Re: Call for defense of @decorators [Python-Dev] Re: Re: Call for defense of @decoratorsSkip Montanaro skip at pobox.com
Tue Aug 10 14:56:27 CEST 2004
    >> I think "adorn" would make a better keyword in that case, as in
    >> "adorn with" this decorator the method foo.

    Bob> I don't think that's appropriate at all.  Most decorators are
    Bob> transformations that change the function object into something else
    Bob> entirely, most likely by wrapping it but quite possibly not.

Correctamundo.  In fact, there's no need that the decorator return a
function (or callable) object at all.  You could define a function to
compute a lookup table of some sort.  The decorator might simply invoke the
function and return its value.  Perfectly legal.  Slightly more than
adornment.  Somewhat silly example:

    def define(func):
        return func()

    @ define
    def grayscale():
        table = []
        for i in range(256):
            table.append((i,i,i))
        return table

Skip
More information about the Python-Dev mailing list

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