Update module_loading documents

This commit is contained in:
Yue Gong 2017-03-25 17:59:01 +08:00
parent 087f1c55cd
commit 3822d6568e

View File

@ -5,7 +5,10 @@ from importlib import import_module
def import_string(dotted_path, dotted_attributes=None):
"""
Import a dotted module path and return the attribute/class designated by the
last name in the path. Raise ImportError if the import failed.
last name in the path. When a dotted attribute path is also provided, the
dotted attribute path would be applied to the attribute/class retrieved from
the first step, and return the corresponding value designated by the
attribute path. Raise ImportError if the import failed.
"""
try:
module_path, class_name = dotted_path.rsplit('.', 1)