wineColoredDays's blog

By wineColoredDays, history, 7 years ago, In English

To all the Python Gods out there, can you please explain the concept of decorators in Python.

I need to understand how it works, what are its advantages, how can be it applied over functions and classes. And hold, how you keep track when there are multiple decorators applied to the same class or function. I mean how you visualize.

Thanks in advance :)

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

.....waiting....

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Basically this question is quite large, but actually I don't see possible use cases of this pattern in competitive programming (except for some kind of 'memo' decorators, probably)

Anyway I guess that simplest way to describe how it works is to see what are common use cases: https://www.quora.com/What-are-common-uses-of-Python-decorators Additionally, you can read PEP 318: https://www.python.org/dev/peps/pep-0318/

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I came across decorators while going through a code base in my job, it has nothing to do with CP. Thanks, though :)