Python: From outside Class access to variable in method other than __self__(init) -


there example @ http://effbot.org/tkinterbook/tkinter-dialog-windows.htm , 1 thing don't understand:

class dialog(toplevel):      ...          self.result = none  ...  class mydialog(dialog):      def apply(self):         first = int(self.e1.get())         second = int(self.e2.get())         self.result = first, second  d = mydialog(root) print d.result 

they access self.result inside apply method referring d.result.

i tried reconstruct own simple example:

class mother(object):   def __init__(self):     self.result = none   def apply(self):     pass  class class(mother):   def apply(self):     self.result = "hello"  d = class() print d.result 

the output of print d.result none instead of "hello"

please help.

you never called d.apply() set result "hello".


Comments