"""
This might pop up if you're trying to use a class directly,
rather than instantiating it. The "missing" argument is "self"
corresponding to the object that you didn't instantiate
"""
class MyClass:
def __init__(self, attr) -> None:
self.attr = attr
def get_attr (self):
return self.attr
# CORRECT
object_of_myclass = MyClass(1)
print (type(object_of_myclass)) # <class '__main__.MyClass'>
print (object_of_myclass.get_attr()) # 1
# INCORRECT
myclass = MyClass
print (type(myclass)) # <class 'type'>
print (myclass.get_attr())
# TypeError: get_attr() missing 1 required positional argument: 'self'