Error in writting a class.

Posted by Richard on Stack Overflow See other posts from Stack Overflow or by Richard
Published on 2010-04-22T14:20:56Z Indexed on 2010/04/22 14:23 UTC
Read the original article Hit count: 309

Filed under:
|

I am running through a tutorial online at http://www.sthurlow.com/python/lesson08/ and I believe I understand how classes work in python, at least to some degree but when I run this code: class Shape: def init(self,x,y): self.x = x self.y = y description = "This shape has not been described yet" author = "Nobody has claimed to make this shape yet" def area(self): return self.x * self.y def perimeter(self): return 2 * self.x + 2 * self.y def describe(self,text): self.description = text def authorName(self,text): self.author = text def scaleSize(self,scale): self.x = self.x * scale self.y = self.y * scale

I get this error:

Traceback (most recent call last): File "Y:/python/Shape.py", line 1, in -toplevel- class Shape: File "Y:/python/Shape.py", line 17, in Shape self.y = self.y * scale NameError: name 'self' is not defined

Any Help would be great

Thanks

Richard

© Stack Overflow or respective owner

Related posts about python

Related posts about class