diff options
author | Brett Cannon <brett@python.org> | 2013-06-15 02:49:00 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-06-15 02:49:00 (GMT) |
commit | 4f422e34148f0f574ad2f6725f5299eaf8f35bcd (patch) | |
tree | f81480c74e2a1b01a195efe842d6add2a6c98397 /Doc | |
parent | 82b3d6ae93b2414ba3b2f69ad18c49c12fdaacb9 (diff) | |
download | cpython-4f422e34148f0f574ad2f6725f5299eaf8f35bcd.zip cpython-4f422e34148f0f574ad2f6725f5299eaf8f35bcd.tar.gz cpython-4f422e34148f0f574ad2f6725f5299eaf8f35bcd.tar.bz2 |
Issue #17177: Update the programming FAQ to use importlib
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/faq/programming.rst | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 4cf3b60..1c5e12f 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -1738,12 +1738,12 @@ When I edit an imported module and reimport it, the changes don't show up. Why 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 @@ module contains class definitions, existing class instances will *not* be 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 |