I created a "project" with Spyder and wrote a few classes that I stored into separate files (I would call the files "module" but I am not sure it is the proper way to call it).
I read that the __init__.py
file is meant to avoid unwanted overwriting of names.
Is it a proper way to program in Python if I use __init__.py
to initialize things for all my "modules": define constants (eg. debug level), "calculated" values (eg. system encoding), imports, start a global debugging function (tuned for my needs), etc. ?
In other words: What is the best way to do the initialization?
- Leave
__init__.py
empty and initialize my values in another "module" which will be called a/ at the beginning of each "module" or b/ by each one of the__init__()
of the classes? - If I use
__init__.py
and import it in every "module" for initialization, Spyder warns because I don't use it explicitly: I am actually doing something wrong or should I ignore the warning? - Should I put the definition of constants in a
Config.ini
file and get it throughconfigparser.ConfigParser()
? or just define it directly in the initialization module (__init__.py
or another) ?
Thanks in advance for your insights.
Pierre.