What are the "best practices" for using import in a module?
In general, don’t use the from modulename import * form of import. Doing so clutters the importer’s namespace. Some people avoid this idiom even with modules like Tkinter and threading that are intentionally designed to be imported in this manner.
Import modules at the top of a file. Doing so makes it clear what other modules your code requires and avoids questions of whether the module name is in scope. Using one import per line makes it easy to add and delete module imports, but using multiple imports per line uses less screen space.
It’s good practice if you import modules in the following order:
- standard library modules — e.g. sys, os, getopt, re)
- third-party library modules (anything installed in Python’s site-packages directory) — e.g. mx.DateTime, ZODB, PIL.Image, etc.
- locally-developed modules
Avoid relative package imports. If you’re writing code th