With or without parenthesis, is there a difference?
class Host:
def __init__(self, ip, elements):
class Interface():
def __init__(self, localIP, remoteIP, numHops, hops):
With or without parenthesis, is there a difference?
class Host:
def __init__(self, ip, elements):
class Interface():
def __init__(self, localIP, remoteIP, numHops, hops):
No, there is no difference whatsoever, and any half-decent IDE will suggest you to "remove redundant parenthesis".
In Python 2 days there was a difference between class Host and class Host(object) (see What is the difference between old style and new style classes in Python?).
In Python 3, class Host, class Host(object) and class Host() are all equivalent.
Typically, parentheses in class definitions are used to indicate inheritance:
class Interface(baseClass):
If your class does not inherit any properties from another object, then it is more natural to omit parentheses:
class Interface: