[Python-Dev] Re: Another approach to decorators. (original) (raw)
David Abrahams dave at boost-consulting.com
Thu Aug 12 20:05:04 CEST 2004
- Previous message: [Python-Dev] Re: Another approach to decorators.
- Next message: [Python-Dev] Re: Re: Decimal type question [Prothon]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
David Eppstein <eppstein at ics.uci.edu> writes:
In article <un011l2qz.fsf at boost-consulting.com>, David Abrahams <dave at boost-consulting.com> wrote:
> class Foo: > > decorate static: > > def static1(blah...): > pass > > decorate locksFile: > > def static2andLocks(blah...): # both decorators appy > pass
Wow, Martin Z's idea (using your keyword) really went "thunk" for me. What decorate does would be very much like what "class" does in some ways. class: (and other something: constructs) start a block that can contain any code. Does this decorate keyword allow e.g. assignments as well as defs and other decorates? Or loops?
Why not? class: starts a block that establishes a new dict as the execution namespace and then passes the result off to the metaclass. decorate might do the same.
If so what should it mean?
Whatever the user wants, I guess?
Is it like that locals() gets replaced by a special dictionary-like-object that calls the decorator whenever any of its contents gets set?
I was thinking it calls the decorator afterwards, just like class calls the metaclass afterwards.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
- Previous message: [Python-Dev] Re: Another approach to decorators.
- Next message: [Python-Dev] Re: Re: Decimal type question [Prothon]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]