0

Hi all,

How can I declare a global variable inside a module and use it across other modules for throughout the lifecycle of the program?

Regards,
Dinil

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Stefano Mtangoo
0

So i take it your making you own module and importing it right? Well if you import a module you can access its variables by going

module.variable

If you have imported the module then the module is global and therefore there is global access to the variable.

If that isnt it, would you mind clearing it up a bit, in more detail.

0

Hi ...
Thanks for the suggestions. I will have to check my code again if this really works out. Any way will get back if I am stuck somewhere!!!..

Regards,
Dinil

0

+1 for you!

#here are global values
import wx
import random
#here are global values

class MyFrame(wx.Frame):
    #here are only class methods
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(180, 380))

#Global to the rest of the code but not the first class MyFrame
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.