0 votes
1 view
in Python by (44.6k points)
I am currently learning Python, from that, I got to know about method decorators. I want to ask that can we decorate the classes?

1 Answer

0 votes
by (96.2k points)

Yes, you can easily decorate the classes, it is just a method that takes some arguments:

That argument can be anything, it can be the class as well.

#!/usr/bin/env python3

def decorate(cls):


    return cls


class Foo: pass

$ python example.py


$ python3 example.py

<class '__main__.Foo'>

The class decorator will return an arbitrary object as the output.

If you want to know more about Python, the do refer to the Python certification course.

Related questions

0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer
asked Oct 30, 2019 in Python by humble gumble (20k points)
0 votes
1 answer
asked Oct 15, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !