Global variables

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,

Rajendra

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

This is a list about wxPython, not about python in general. If you want to ask a question about general programming in python, look at the python-users mailing list (http://mail.python.org/mailman/listinfo/python-list). As a general rule, though, you are expected to look at the language documentation before posting to a list. Try looking at the Python tutorial. Read the part about how to use packages.

http://docs.python.org/tutorial/index.html

ยทยทยท

From: Rajendra Arvind Gai Rajendra_ArvindGai@infosys.com
To: "wxpython-users@lists.wxwidgets.org" wxpython-users@lists.wxwidgets.org
Sent: Friday, November 14, 2008 12:46:34 AM
Subject: [wxpython-users] Global variables

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,

Rajendra

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
 address. Messages sent to or from this e-mail address may be stored on
the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Rajendra Arvind Gai wrote:

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?

This is what I do -

Create a separate file/module to store my globals - I call mine 'common.py'.

At the top of all my other modules, I have the line 'import common as c'.

I can then read/write any of the variables as 'c.whatever'.

HTH

Frank Millman

Frank Millman wrote:

Rajendra Arvind Gai wrote:
  

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?

This is what I do -

Create a separate file/module to store my globals - I call mine 'common.py'.

At the top of all my other modules, I have the line 'import common as c'.

I can then read/write any of the variables as 'c.whatever'.

HTH

Frank Millman
  
+1

I have used this method as well. Ben also has a point though. This group is mostly for wxPython related questions. There's both the general Python mailing list and a tutor list. I think you will find those quite helpful for this sort of thing.

Mike