png py tiff py jpeg py the import statement is used to load modules from package in number of waysn import graphics primitive fill this loads the submodule graphics primitive fill the contents of this module have to be explicitly namedsuch as graphics primitive fill floodfill(img, , ,colorn from graphics primitive import fill this loads the submodule fill but makes it available without the package prefixfor examplefill floodfill(img, , ,colorn from graphics primitive fill import floodfill this loads the submodule fill but makes the floodfill function directly accessiblefor examplefloodfill(img, , ,colorwhenever any part of package is first importedthe code in the file _init_ py is executed minimallythis file may be emptybut it can also contain code to perform package-specific initializations all the _init_ py files encountered during an import are executed thereforethe statement import graphics primitive fillshown earlierwould first execute the _init_ py file in the graphics directory and then the _init_ py file in the primitive directory one peculiar problem with packages is the handling of this statementfrom graphics primitive import programmer who uses this statement usually wants to import all the submodules associated with package into the current namespace howeverbecause filename conventions vary from system to system (especially with regard to case sensitivity)python cannot accurately determine what modules those might be as resultthis statement just imports all the names that are defined in the _init_ py file in the primitive directory this behavior can be modified by defining list_ _all_ _that contains all the module names associated with the package this list should be defined in the package _init_ py filelike thisgraphics/primitive/ _init_ py _all_ ["lines","text","fill"now when the user issues from graphics primitive import statementall the listed submodules are loaded as expected another subtle problem with packages concerns submodules that want to import other submodules within the same package for examplesuppose the graphics primitive fill module wants to import the graphics primitive lines module to do thisyou can simply use the fully specified named ( from graphics primitives import linesor use package relative import like thisfill py from import lines in this examplethe used in the statement from import lines refers to the same directory of the calling module thusthis statement looks for module lines in the lib fl ff