Module import best practice

Rich Shepard rshepard at appl-ecosys.com
Wed Mar 25 16:09:18 EDT 2020


I'm writing an application using Python3 and Tkinter. The views/ directory
contain multiple modules, including one called commonDlgs.py. This contains
classes (such as those for validating data entry) used by all the data entry
views. Some classes in commonDlgs imports other modules.

My question is whether to import into each view class those modules needed
by it or import all supporting modules at the top of commonDlgs.py, then
import that module in each view with:

from . import commonDlgs as cd

rather than importing specific classes in each view module?

Rich


More information about the Python-list mailing list