From e4aad5ab3242f2a346b2c86ff84e19d96e7a7b88 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 4 Aug 2014 19:34:29 +0300 Subject: #18034: update FAQ to suggest importlib.import_module instead of __import__. Patch by Wouter van Heyst. --- Doc/faq/programming.rst | 15 +++------------ Misc/ACKS | 1 + 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 71194d0..d85563f 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -1786,19 +1786,10 @@ These solutions are not mutually exclusive. __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 :: - - 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`. +Consider using the convenience function :func:`~importlib.import_module` from +:mod:`importlib` instead:: + 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 --git a/Misc/ACKS b/Misc/ACKS index 87a3264..08ca65f 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -549,6 +549,7 @@ Bernhard Herzog Magnus L. Hetland Raymond Hettinger Kevan Heydon +Wouter van Heyst Kelsey Hightower Jason Hildebrand Richie Hindle -- cgit v0.12