software design question

Uwe Mayer merkosh at
Sat Feb 7 13:16:05 CET 2004


I have the following inter-class relationships:

__main__:  (in file
  imports module FileIO
  defines class LMCMain 
  instanciats main = LMCMain(...)
  defines class FileIO
  class FileIO needs to access "main" from

In I've tried to "import LMCMain", but that causes the main
program to be re-executed. I only wanted to access to the main class
instance LMCMain.
My aim is a modular software design. I know this yields much communication
overhead and may become compilcate soon. Here I rely on "its not too slow"
and eventually perhaps psyco. 

A solution I could think of would be a Singleton. Both and import "". stores "main" in singleton and accesses it.
I could also use a static class instead of a public module variable... I
don't really know whats better.

I'd like to fall back on some design pattern, but somehow you can only use
them, once you're used to them (i.e. theoretical knowledge does not
I also learned much from the "logging" module and the Qt SIGNAL-SLOT concept
which IMO are excellently designed.

I know this is not strictly related to Python, but since I'm working in
Python I'd like to hear pythoneers suggestion to it.

Thanks in advance

More information about the Python-list mailing list