Different class declaration ways?

Hi, I noticed, there are two ways to declare classes.

  1. def class Rectangle():
  2. `def class User:

Notice there are two ways to declare classes, one is ending with parenthesis and one is not. Just wondering what is the difference between the two? Can anyone please tell?`

Hi Manzar,

This is Waleed from Educative. I am glad you reached out to us.

Both, class User and class User(), work the same way in Python code. We use them to improve readability of the code in different contexts

For example, we usually use class User() when working with class inheritances. The parenthesis helps us identify that class User() does not inherit any class.

Best Regards,
Waleed | Developer Advocate