Shrutarshi Basu wrote:
> I'm working on a module consisting of a number of scripts that handle
> communications over a serial connection. I would like someway for the
> user to be able to specify which serial port to be used based on a
> config file in the same directory as the user's program. Should I
> place the parsing system in the module's init.py, considering that the
> port will actually be accessed by a different python script in the
> same module? How could I then let the other scripts access the port
> information obtained by the parser?

There are several common ways to do this.
- have a configuration module that parses the settings and contains the 
results. Modules that need access to the configuration import the config 
module and read its values
- create a configuration object that is passed as a parameter to 
functions that need it, or pass individual configuration items to the 
functions.
- create a configuration object that is stored as an attribute of a 
class and accessed that way

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to