By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

global variables in module

P: n/a
Hi to all!

I'm writing a GUI with wxPython. I want to save preferences and defaults
values in a configuration file. I'm going ot parse this file using
ConfigParse from the standar library.

In my application i've

MyApp(wxApp):
...
def OnInit(self):
..
cf = ConfigParse.ConfigParse()
cf.read(open("defaults.cfg"))

How can i use cf in other modules of the program. Did I need declare cf
global, or make it a module variable, ... Any hint, please

TIA

Zunbeltz
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Zunbeltz,
MyApp(wxApp):
How can i use cf in other modules of the program. Did I need declare cf
global, or make it a module variable, ... Any hint, please


is used the following approach:

1) defining one module named

ReportGlobals

loggedInUser="nasenbaer"
workerQueue=Queue.Queue()

there all varibles which are "konfiguration related" are defined, also
"programm global queues", "error loggers", "database connection pool"

All these variables are defined as module level variables
(on "indent 0" :))) )

2) in all modules of the programm I use

import ReportGlobals as gl

print "You are %s" % (gl.loggedInUser,)
HTH

Harald

and access the
Jul 18 '05 #2

P: n/a
Harald Massa <cp*********@spamgourmet.com> writes:
Zunbeltz,
MyApp(wxApp):
How can i use cf in other modules of the program. Did I need declare cf
global, or make it a module variable, ... Any hint, please
is used the following approach:

1) defining one module named


I've take another aproach. I've created a module where I define a class
derived from ConfigParse. I've take the idea from the source of idle.
ReportGlobals

loggedInUser="nasenbaer"
workerQueue=Queue.Queue()

there all varibles which are "konfiguration related" are defined, also
"programm global queues", "error loggers", "database connection pool"

All these variables are defined as module level variables
(on "indent 0" :))) )

2) in all modules of the programm I use

import ReportGlobals as gl

print "You are %s" % (gl.loggedInUser,)
HTH

Harald

Thanks for your answer

Regards,

Zunbeltz

and access the

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.