4

How to access a local variable from another class in Python? Is it possible.?

Comments
  • 1
    Look up encapsulation
  • 0
    if you're using instance variables you have to send the instance of ClassA to ClassB

    if you use class variables you can access them normaly
  • 0
    @koin You worked with pyqt4 module?
  • 0
    @NoMad Worked with pyqt4?
  • 0
    @NoMad Actually what I need is, I have one function which will be called when a button is clicked. I have to store a value from that function and pass it to another class for execution of the backend. Whenever I am trying to call that variable it is not fetching that value.
  • 0
    @NoMad Well actually I did this also. It is giving a null value which I have set to the global variable. How to create a static variable and modify it? I will store the function value in it and use it in another class. Is that possible?
  • 0
    @NoMad Okay. Can you tell how to call the variable in another class?
  • 0
    @NoMad Will definitely try tommorrow at work and will let you know the results. Thank you very much!!!!!!!!!
  • 0
    @neojoy777 no offense, but "at work"? You are a professional?
  • 0
    @willol Yes. Why?
  • 0
    @NoMad It didn't work.
  • 0
    I figured out the issue. Its working fine now
Add Comment