same directory as the file fill py great care should be taken to avoid using statement such as import module to import package submodule in older versions of pythonit was unclear whether the import module statement was referring to standard library module or submodule of package older versions of python would first try to load the module from the same package directory as the submodule where the import statement appeared and then move on to standard library modules if no match was found howeverin python import assumes an absolute path and will simply try to load module from the standard library relative import more clearly states your intentions relative imports can also be used to load submodules contained in different directories of the same package for exampleif the module graphics graph plot wanted to import graphics primitives linesit could use statement like thisplot py from primitives import lines herethe moves out one directory level and primitives drops down into different package directory relative imports can only be specified using the from module import symbol form of the import statement thusstatements such as import primitives lines or import lines are syntax error alsosymbol has to be valid identifier soa statement such as from import primitives lines is also illegal finallyrelative imports can only be used within packageit is illegal to use relative import to refer to modules that are simply located in different directory on the filesystem importing package name alone doesn' import all the submodules contained in the package for examplethe following code doesn' workimport graphics graphics primitive fill floodfill(img, , ,colorfailshoweverbecause the import graphics statement executes the _init_ py file in the graphics directoryrelative imports can be used to load all the submodules automaticallyas followsgraphics/ _init_ py from import primitivegraph dgraph graphics/primitive/ _init_ py from import linesfilltextnow the import graphics statement imports all the submodules and makes them available using their fully qualified names againit is important to stress that package relative import should be used as shown if you use simple statement such as import modulestandard library modules may be loaded instead finallywhen python imports packageit defines special variable_ _path_ _which contains list of directories that are searched when looking for package submodules ( _path_ is package-specific version of the sys path variable_ _path_ is accessible to the code contained in _init_ py files and initially contains single item with the directory name of the package if necessarya package can supply additional directories to the _path_ list to alter the search path used for finding submodules this might be useful if the organization of package on the file system is complicated and doesn' neatly match up with the package hierarchy lib fl ff