changeset: 91996:815f1a69283e branch: 3.4 parent: 91994:9bca86812857 user: Ezio Melotti date: Mon Aug 04 19:34:29 2014 +0300 files: Doc/faq/programming.rst Misc/ACKS description: #18034: update FAQ to suggest importlib.import_module instead of __import__. Patch by Wouter van Heyst. diff -r 9bca86812857 -r 815f1a69283e Doc/faq/programming.rst --- a/Doc/faq/programming.rst Mon Aug 04 11:15:10 2014 -0500 +++ b/Doc/faq/programming.rst Mon Aug 04 19:34:29 2014 +0300 @@ -1786,19 +1786,10 @@ __import__('x.y.z') returns ; how do I get z? --------------------------------------------------------- -Try:: - - __import__('x.y.z').y.z - -For more realistic situations, you may have to do something like :: +Consider using the convenience function :func:`~importlib.import_module` from +:mod:`importlib` instead:: - m = __import__(s) - for i in s.split(".")[1:]: - m = getattr(m, i) - -See :mod:`importlib` for a convenience function called -:func:`~importlib.import_module`. - + z = importlib.import_module('x.y.z') When I edit an imported module and reimport it, the changes don't show up. Why does this happen? diff -r 9bca86812857 -r 815f1a69283e Misc/ACKS --- a/Misc/ACKS Mon Aug 04 11:15:10 2014 -0500 +++ b/Misc/ACKS Mon Aug 04 19:34:29 2014 +0300 @@ -549,6 +549,7 @@ Magnus L. Hetland Raymond Hettinger Kevan Heydon +Wouter van Heyst Kelsey Hightower Jason Hildebrand Richie Hindle

AltStyle によって変換されたページ (->オリジナル) /