0

When do I need to define a class as this:

class test: 

as opposed to this:

class test(): 

In other words, what difference does it make whether or not there is a parenthesis?

2
  • Are you sure you can define class as your second one in Python? Commented Apr 17, 2020 at 2:08
  • I am actually not. That answers my question. Sorry for my silly question. I should have just cheked myself. Commented Apr 17, 2020 at 2:11

2 Answers 2

2

The "class test():" is used when subclassing it, else if inheritence is not employed, use "class test:"

Sign up to request clarification or add additional context in comments.

Comments

1

Parentheses after a class definition are used to indicate inheritance. If you dont inherent it from any other classes. Just simply declare it without parentheses. Look at this for more information.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.