Decorators and how they relate to Python - A little insight please!

jmcantrell at gmail.com jmcantrell at gmail.com
Fri Oct 20 07:38:43 CEST 2006


it's handy for doing things like validation of parameter and return
types. Like...

@accepts(int,int)
@returns(int)
def add(a,b):
    return a+b

On Oct 19, 2:04 pm, "Jerry" <jwe... at gmail.com> wrote:
> I have just started to do some semi-serious programming (not one-off
> specialized scripts) and am loving Python.  I just seem to get most of
> the concepts, the structure, and the classes (something I struggled
> with before in other languages).  I've seen many concepts on the web
> (i.e. stacks, queues, linked lists) and can usually understand them
> pretty well (event if I don't always know when to use them).  Now I've
> come accross decorators and even though I've read the PEP and a little
> in the documentation, I just don't get what they are or what problem
> they are trying to solve.  Can anyone please point me to a general
> discussion of decorators (preferrably explained with Python)?
> 
> Thanks,
> Jerry




More information about the Python-list mailing list