I'm taking my first steps in python programming, I have a class named node
which holds a list of node
s (I think that legal) named sons
. I tried to create a function that returns the length of the list but it fails. Here is my code:
class node:
name="temp"
ID=-1
abstract="a short description"
text="the full description"
sons=[]
def sLen(none):
print ("hello")
return len(self.sons)
and here is the error:
NameError: global name 'self' is not defined
if I try to remove the self:
NameError: global name 'self' is not defined
Clearly I have misunderstood something, but what?