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