Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18786

Re: Calling a variable inside a function of another class

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Calling a variable inside a function of another class
Date 2012-01-10 17:41 -0500
References <5a91e124-b6e9-4e2f-88d6-50a33eb496db@k29g2000vbl.googlegroups.com> <4F0C1AF0.7020101@sequans.com>
Newsgroups comp.lang.python
Message-ID <mailman.4616.1326235515.27778.python-list@python.org> (permalink)

Show all headers | View raw


> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Calling a variable inside a function of another class Yigit Turgut <y.turgut@gmail.com> - 2012-01-07 07:00 -0800
  Re: Calling a variable inside a function of another class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-07 16:01 +0000
    Re: Calling a variable inside a function of another class Yigit Turgut <y.turgut@gmail.com> - 2012-01-07 08:18 -0800
      Re: Calling a variable inside a function of another class Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-01-07 14:03 -0500
  Re: Calling a variable inside a function of another class Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-01-10 12:03 +0100
  Re: Calling a variable inside a function of another class Terry Reedy <tjreedy@udel.edu> - 2012-01-10 17:41 -0500

csiph-web