why the super class can access the subclass's attribute
jeanmichel at sequans.com
Thu Jan 21 11:20:09 CET 2010
> I have sees aprogram like this ,i confusing why super class can access
> the subclass's attribute
> ,this is the program,thanks in advance:
> class MyThread(threading.Thread):
> def join(self):
> return self.result
> class Worker(MyThread):
> import random
> import pdb
> def run(self):
> total = 0
> for i in range(random.randrange(10,100)):
> total +=i
> self.result = total
I don't thing I got your problem.
But in case you are talking about 'result', you could probably say that
"the subclass Worker can access to the super class MyThread 'result'
Also keep in mind that there is no private attributes in python, and
that any object can access any other object attribute, no matter its
class. Of course, you dont want to do that.
More information about the Python-list