I am making a python package where I currently have a structure as below:
application/utils.py
class settings():
function foo():
bla bla bla
class debug():
function bar():
bla bla bla
Then in other modules the import of the settings and debug classes can be done as below:
import application.utils.settings
import application.utils.debug
But now, the classes are getting pretty big and I would like to put them in separates files.
application/utils/settings.py
class settings():
function foo():
bla bla bla
application/utils/debug.py
class debug():
function bar():
bla bla bla
In that case, importing the debug and settings classes would be as below:
import application.utils.settings.settings
import application.utils.debug.debug
That I feel quite unnatural.
Is it the right way to do that or am I missing something?
You can write in
application/utils/__init__.py:Then you will access
SettingsandDebugclasses shorterDon’t name your classes and modules the same. Read PEP8 about naming convention