problems with circular references

Terry Reedy tejarex at yahoo.com
Wed Mar 27 17:15:48 EST 2002


"jimh" <jim at jim.jim> wrote in message
news:a7tbd4$qc7$1 at web1.cup.hp.com...
> 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?

I would probably follow the standard Python idiom of using exceptions
instead of numeric error codes, and look at standard library modules
for precedents.

Terry J. Reedy






More information about the Python-list mailing list