[Tutor] Should config file parser be in module's __init__.py

Kent Johnson kent37 at tds.net
Wed Mar 19 11:44:54 CET 2008

Shrutarshi Basu wrote:
> Thanks for that, i think that creating a configuration submodule and
> importing it into the modules that need it will be the most elegant
> solution for me. I was wondering whether the following solution would
> work / be good practice?
> 1. have the parser system in __init__.py

You could do that but I would put it in a config module.

> 2. have the parser store the result in a string, say confstr

If you only have one configuration parameter this is OK. If you have 
multiple parameters you should put them in a class or dict, otherwise 
the individual modules still have to parse the string.

> 3. have modules in the package access it with __init__.confstr

No, if it is in __init__.py you access it at package scope, it would be 


PS Please use Reply All to reply to the list.

More information about the Tutor mailing list