class_docstr: PEP 328 introduced relative imports. This allows for imports to occur
  from within a package without having to specify the actual package name.
  
  A simple example is to import another module within the same package
  [module from module]::
  
    # From pkg.mod1 with pkg.mod2 being a module.
    from . import mod2
  
  This also works for getting an attribute from a module that is specified
  in a relative fashion [attr from module]::
  
    # From pkg.mod1.
    from .mod2 import attr
  
  But this is in no way restricted to working between modules; it works
  from [package to module],::
  
    # From pkg, importing pkg.module which is a module.
    from . import module
  
  [module to package],::
  
    # Pull attr from pkg, called from pkg.module which is a module.
    from . import attr
  
  and [package to package]::
  
    # From pkg.subpkg1 (both pkg.subpkg[1,2] are packages).
    from .. import subpkg2
  
  The number of dots used is in no way restricted [deep import]::
  
    # Import pkg.attr from pkg.pkg1.pkg2.pkg3.pkg4.pkg5.
    from ...... import attr
  
  To prevent someone from accessing code that is outside of a package, one
  cannot reach the location containing the root package itself::
  
    # From pkg.__init__ [too high from package]
    from .. import top_level
  
    # From pkg.module [too high from module]
    from .. import top_level
  
   Relative imports are the only type of import that allow for an empty
   module name for an import [empty name].
class_docstr_tok: ["PEP","328","introduced","relative","imports",".","This","allows","for","imports","to","occur","from","within","a","package","without","having","to","specify","the","actual","package","name",".","A","simple","example","is","to","import","another","module","within","the","same","package","[","module","from","module","]",":",":","#","From","pkg.mod1","with","pkg.mod2","being","a","module",".","from",".","import","mod2","This","also","works","for","getting","an","attribute","from","a","module","that","is","specified","in","a","relative","fashion","[","attr","from","module","]",":",":","#","From","pkg.mod1",".","from",".mod2","import","attr","But","this","is","in","no","way","restricted","to","working","between","modules",";","it","works","from","[","package","to","module","]",",",":",":","#","From","pkg",",","importing","pkg.module","which","is","a","module",".","from",".","import","module","[","module","to","package","]",",",":",":","#","Pull","attr","from","pkg",",","called","from","pkg.module","which","is","a","module",".","from",".","import","attr","and","[","package","to","package","]",":",":","#","From","pkg.subpkg1","(","both","pkg.subpkg","[","1,2","]","are","packages",")",".","from","..","import","subpkg2","The","number","of","dots","used","is","in","no","way","restricted","[","deep","import","]",":",":","#","Import","pkg.attr","from","pkg.pkg1.pkg2.pkg3.pkg4.pkg5",".","from","......","import","attr","To","prevent","someone","from","accessing","code","that","is","outside","of","a","package",",","one","can","not","reach","the","location","containing","the","root","package","itself",":",":","#","From","pkg.__init__","[","too","high","from","package","]","from","..","import","top_level","#","From","pkg.module","[","too","high","from","module","]","from","..","import","top_level","Relative","imports","are","the","only","type","of","import","that","allow","for","an","empty","module","name","for","an","import","[","empty","name","]","."]
code: def test_import_from_different_package(self):
      # Test importing from a different package than the caller.
      # in pkg.subpkg1.mod
      # from ..subpkg2 import mod
      create = [
          "__runpy_pkg__.__init__",
          "__runpy_pkg__.__runpy_pkg__.__init__",
          "__runpy_pkg__.uncle.__init__",
          "__runpy_pkg__.uncle.cousin.__init__",
          "__runpy_pkg__.uncle.cousin.nephew",
      ]
      globals_ = {"__package__": "__runpy_pkg__.__runpy_pkg__"}
  
      def callback(global_):
          self.__import__("__runpy_pkg__.__runpy_pkg__")
          module = self.__import__(
              "uncle.cousin", globals_, {}, fromlist=["nephew"], level=2
          )
          self.assertEqual(
              module.__name__, "__runpy_pkg__.uncle.cousin"
          )
  
      self.relative_import_test(create, globals_, callback)
  
file_path: cpython/Lib/test/test_importlib/import_/test_relative_imports.py
imports: from test.test_importlib import util
  import unittest
  import warnings
label_desc: Use image node_id 11 for calling the RelativeImports obj's underlying member method code with example usage: obj.test_import_from_different_package() without return types