[Tutor] Should config file parser be in module's __init__.py
kent37 at tds.net
Wed Mar 19 22:46:37 CET 2008
Shrutarshi Basu wrote:
> Ok, I'm starting to understand how things work. Just one last
> question: suppose my package has a config.py (which contains a config
> dict) which another module in the package imports by "import config".
> If the user of my package has a config.py in the directory from where
> they run their program (which uses my package), then which config.py
> will be used? The user's or the packages? The python tutorial section
> on modules leads me to believe it will be the users, since the current
> directory is searched first, but I'm not sure because it is my package
> which does the import, not the users program.
It will be the user's config.py.
Look at sys.path to see the order in which directories are searched for
More information about the Tutor