problems with circular references

Susan Williams susan at mars.provis.com
Wed Mar 27 16:45:16 EST 2002


>
>I am working on python code that consist of quite a few files (about 50;
>each file contains one class).  All errors returned by functions are numeric
>and are defined in the individual files.  There is a MessageCatalog.py class
>which will map these numbers into strings.  This MessageCatalog.py has to
>import all of the 50 other files to have access to their error numbers.  So
>far, so good - no problems yet.
>
>Here is the problem: Most of these 50 classes need to use the MessageCatalog
>themselves.  This means, of course, that classA imports MessageCatalog which
>imports classA.  This doesn't work very well.
>
>Does anyone have ideas on how to deal with this situation?
>
>Thanks,
>Jim

It sounds as though somehow or other you want to put the
actual error number data for each class into MessageCatalog
and give the 50 classes some interface for registering
their error numbers with MessageCatalog.  Then MessageCatalog
is oblivious to what other classes there are, except that
at run time they tell it about themselves.  You could add
another object for holding the error number data
and have one instance per class---if that provides a convenient 
structure for accessing the error number data...

susan





More information about the Python-list mailing list