This is reference to the 5th video in the “Classes” section of Mosh’s “Complete Python Mastery”. My code is slightly different than Mosh’s, as I kept the “MyPoint” as the class name. Mosh defines a class method “zero” to set an object for this class to have the initial parameters of (0,0). My code (below) returns an error, “AttributeError: ‘NoneType’ object has no attribute ‘draw’”. I have reviewed Mosh’s code several times and see no meaningful difference in his and mine, or any reason why mine shouldn’t work:
class MyPoint:
@classmethod
def zero(cls):
cls(0, 0)
def __init__(self, x, y):
self.x = x
self.y = y
def draw(self):
print(f"Point ({self.x},{self.y})")
point = MyPoint.zero()
print(type(point))
point.draw()