What does `@` mean in Python?

后端 未结 6 1629
盖世英雄少女心
盖世英雄少女心 2021-01-19 15:40

What does @ mean in Python?

Example: @login_required, etc.

6条回答
  •  攒了一身酷
    2021-01-19 16:16

    A decorator, also called pie syntax. It allows you to "decorate" a function with another function. You already had decoration with staticmethod() and classmethod(). The pie syntax makes it more easy to access and extend.

提交回复
热议问题