Im learning about OOP in Python and I wrote this code,I tried executing a function in another,both of which belongs to the same class but it gave an error message.The code is
kudi = 28
print 'kudi is=%s'%kudi
if int(kudi) == 28:
s = 'champagne'
print "Kudi != 28"
print 'kudi is:%s'%(kudi*3)
something = dumb(int(raw_input('>')))
NameError: global name 'faithful' is not defined
There are some mistakes in your code.
From there on, I will assume that you wanted to make
faithful member functions, that is functions applicable for the
dumb class because you tried to call
selfas their first arguments.
faithful(s), you are trying to call a global function (defined outside the class) with
sas argument. To call the
faithfulfunction of the
dumbclass, the syntax is
something.dear()which doesn't work because
deartakes an argument
kudian attribute of
dumbor whatever, but not a global variable.