# Creating a class method leads to error when defining/calling object

**URL:** <https://forum.codewithmosh.com/t/creating-a-class-method-leads-to-error-when-defining-calling-object/13950>\
**Category:** Python\
**Created:** [July 27, 2022, 1:30am UTC](https://forum.codewithmosh.com/t/creating-a-class-method-leads-to-error-when-defining-calling-object/13950 "2022-07-27T01:30:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgeist12](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@tgeist12](https://forum.codewithmosh.com/u/tgeist12)\
**Post date:** [July 27, 2022, 1:30am UTC](https://forum.codewithmosh.com/t/creating-a-class-method-leads-to-error-when-defining-calling-object/13950/1 "2022-07-27T01:30:17Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [July 27, 2022, 2:50am UTC](https://forum.codewithmosh.com/t/creating-a-class-method-leads-to-error-when-defining-calling-object/13950/2 "2022-07-27T02:50:32Z")

</div>

I believe you need the `return` keyword to return the object from your `zero` method. Right now it returns nothing (hence the `NoneType`).
