[Python-checkins] cpython: Issue #17177: Update the programming FAQ to use importlib
brett.cannon
python-checkins at python.org
Sat Jun 15 04:49:10 CEST 2013
http://hg.python.org/cpython/rev/3d3b9d456eb8
changeset: 84138:3d3b9d456eb8
user: Brett Cannon <brett at python.org>
date: Fri Jun 14 22:49:00 2013 -0400
summary:
Issue #17177: Update the programming FAQ to use importlib
files:
Doc/faq/programming.rst | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -1738,12 +1738,12 @@
For reasons of efficiency as well as consistency, Python only reads the module
file on the first time a module is imported. If it didn't, in a program
consisting of many modules where each one imports the same basic module, the
-basic module would be parsed and re-parsed many times. To force rereading of a
+basic module would be parsed and re-parsed many times. To force re-reading of a
changed module, do this::
- import imp
+ import importlib
import modname
- imp.reload(modname)
+ importlib.reload(modname)
Warning: this technique is not 100% fool-proof. In particular, modules
containing statements like ::
@@ -1755,10 +1755,10 @@
updated to use the new class definition. This can result in the following
paradoxical behaviour:
- >>> import imp
+ >>> import importlib
>>> import cls
>>> c = cls.C() # Create an instance of C
- >>> imp.reload(cls)
+ >>> importlib.reload(cls)
<module 'cls' from 'cls.py'>
>>> isinstance(c, cls.C) # isinstance is false?!?
False
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list