Calling a variable inside a function of another class

Terry Reedy tjreedy at udel.edu
Tue Jan 10 17:41:54 EST 2012


> Yigit Turgut wrote:
>> class test(test1):
>>
>> def __init__(self, device):
>> .
>> .
>> .
>> def _something(self, x=1)
>> self.dt = data
>>
>>
>> if __name__ == "__main__":
>> test.something.dt ???
>>
>> I am trying to call a variable located in a function of a class

dt is an attribute of an instance of the class.
   t = test() # create instance
   t._something() # call method that assigns attribute to t
   t.dt  # is not the value of dt for t

-- 
Terry Jan Reedy




More information about the Python-list mailing list