The module in Example 15-2 implements a shared, system-wide namespace that collects resources used in most modules in the system, and defines global objects that span files. This allows other files to avoid redundantly repeating common imports, and encapsulates the locations of package imports; it is the only file that must be updated if paths change in the future. Using globals can make programs harder to understand in general (the source of some names is not as clear), but it is reasonable if all such names are collected in a single expected module such as this one (because there is only one place to search for unknown names). Example 15-2. PP3E\Internet\Email\PyMailGui\SharedNames.py ################################################################ # objects shared by all window classes and main file: program-wide globals ############################################################### # used in all window, icon titles # used for list save, open, delete; also for sent messages file # currently viewed mail save files; also for sent-mail file # standard library services # reuse book examples
def printStack(exc_info): # thread busy counters for threads run by this GUI loadingHdrsBusy = threadtools.ThreadCounter() # only 1
blog comments powered by Disqus |