the package directory firstother dot-based relative reference patterns are possibletoo within module file located in package directory named mypkgthe following alternative import forms work as describedfrom string import name name from import string from import string imports names from mypkg string imports mypkg string imports string sibling of mypkg to understand these latter forms betterand to justify all this added complexitywe need to take short detour to explore the rationale behind this change why relative importsbesides making intrapackage imports more explicitthis feature is designed in part to allow scripts to resolve ambiguities that can arise when same-named file appears in multiple places on the module search path consider the following package directorymypkg__init__ py main py string py this defines package named mypkg containing modules named mypkg main and mypkg string nowsuppose that the main module tries to import module named string in python and earlierpython will first look in the mypkg directory to perform relative import it will find and import the string py file located thereassigning it to the name string in the mypkg main module' namespace it could bethoughthat the intent of this import was to load the python standard library' string module instead unfortunatelyin these versions of pythonthere' no straightforward way to ignore mypkg string and look for the standard library' string module located on the module search path moreoverwe cannot resolve this with full package import pathsbecause we cannot depend on any extra package directory structure above the standard library being present on every machine in other wordssimple imports in packages can be both ambiguous and error-prone within packageit' not clear whether an import spam statement refers to module within or outside the package as one consequencea local module or package can hide another hanging directly off of sys pathwhether intentionally or not in practicepython users can avoid reusing the names of standard library modules they need for modules of their own (if you need the standard stringdon' name new module string!but this doesn' help if package accidentally hides standard modulemoreoverpython might add new standard library module in the future that has the same name as module of your own code that relies on relative imports is also module packages