On Wed, Jul 6, 2016 at 3:35 PM, bruce <badoug...@gmail.com> wrote:

> Hi.
>
> Saw the decorator thread earlier.. didn't want to pollute it. I know, I
> could google!
>
> But, what are decorators, why are decorators? who decided you needed them!
>

They're functions that modify the decorated function. If I make a function
that performs a task, I might decorate with a logging function:

@logThis
def doSomething():
  #do stuff

The logThis decorator could log the run, or modify the doSomething output,
or do any number of tasks. To get that extra functionality, I need only
decorate my own function. I see these a lot in Flask, a web framework,
where they are used to define what parts of your website are handled by
what functions, for instance. Basically, they let you extend what your
functions do without needing to subclass anything.

>
> Thanks!
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Alex Hall
Automatic Distributors, IT department
ah...@autodist.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to