Hi there,
could you help me spot my error - I'm sure it's a simple one. I'm just trying to understand classes in Python a little better (working through Learn Python The Hard Way).
Basically I want the printokay function in Testclass2 to run after being called from Testclass1
could you help me spot my error - I'm sure it's a simple one. I'm just trying to understand classes in Python a little better (working through Learn Python The Hard Way).
Basically I want the printokay function in Testclass2 to run after being called from Testclass1
Code:
class Testclass1(object):
def __init__(self, var1):
self.printthis = var1
def printthing(self):
lookatme = self.printthis
Testclass2(lookatme).printokay()
class Testclass2(object):
def __init(self, var2):
self.okayletsprint = var2
def printokay(self):
print "this is text"
print self.okayletsprint
a = Testclass1("jumbo")
a.printthing()
Comment