Блог пользователя wineColoredDays

Автор wineColoredDays, история, 8 лет назад, По-английски

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 :)

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

.....waiting....

»
8 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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/

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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