The problem is: 'myclass' has a different behaviour than the dht class, and I can't figure out what is causing it.
myclass.py:
Code: Select all
class MyBase:
def __init__(self):
self.temp = 1
self.printinfo(self)
def measure(self):
self.temp = 23
def printinfo(self):
print("This is info from MyBase")
class Hello1(MyBase):
def printinfo1(self):
print("This is info from Hello1 ")
def getv(self):
t = self.temp
return t
class Hello2(MyBase):
def printinfo1(self):
print("This is info from Hello2")
def getv(self):
t = "Hello2"
return t
Code: Select all
import myclass
hello1 = myclass.Hello1
hello1.getv()
okay, then i try.
Code: Select all
hello1.getv(hello1)
--> AttributeError: type object 'Hello1' has no attribute 'temp' (apparantly it dit not run __init__??, why?)
okay, so i need to manually run __init__.
Code: Select all
hello1.__init__(hello1)
Code: Select all
hello1.getv(hello1)
Code: Select all
hello1.measure(hello1)
hello1.getv(hello1)
So what is the essential difference between the dht class and 'myclass'?, or what am I doing wrong?
This has to be a simple beginners question
edit: code in codetags