Multiple decorators in Python

LatM0919 report abuse

Hi everybody, I'm trying to learn some advanced Python and I have hit the concept of decorators in Python. I managed to create and use one successfully. But is it possible to apply several decorators to the same function?

Answers

PyAnto report abuse

@LatM0919

Yes, it is possible. You can simply list them one below another before the target function definition.

LatM0919 report abuse

Ok, thanks. Is the order in which I will mention decorators matters?

PyAnto report abuse

Decorators will behave as nested functions. This means that the order has the meaning. The very top decorator will be applied for all decorators that go after it and to the target function as well.

LatM0919 report abuse

Thanks

Add Answer

Need support?

Just drop us an email to ... Show more