summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorTzu-ping Chung <uranusjr@gmail.com>2019-07-25 17:20:33 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-25 17:20:33 (GMT)
commit544fa15ea1b7b73068319bdb217b684e2fd7bacc (patch)
tree1674fadbbe05e7a3af06e7b79c0127b4c0d749ef /Doc
parent898318b53d921298d1f1fcfa0f415844afbeb318 (diff)
downloadcpython-544fa15ea1b7b73068319bdb217b684e2fd7bacc.zip
cpython-544fa15ea1b7b73068319bdb217b684e2fd7bacc.tar.gz
cpython-544fa15ea1b7b73068319bdb217b684e2fd7bacc.tar.bz2
Swap 'if' branches so content matches to condition in importlib example (GH-14947)
Prior to this change the guard on an 'elif' used an assignment expression whose value was used in a later 'else' block, causing some confusion for people. (Discussion on Twitter: https://twitter.com/brettsky/status/1153861041068994566.) Automerge-Triggered-By: @brettcannon
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/importlib.rst6
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 9fab077..65a6850 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1640,14 +1640,14 @@ import, then you should use :func:`importlib.util.find_spec`.
if name in sys.modules:
print(f"{name!r} already in sys.modules")
- elif (spec := importlib.util.find_spec(name)) is None:
- print(f"can't find the {name!r} module")
- else:
+ elif (spec := importlib.util.find_spec(name)) is not None:
# If you chose to perform the actual import ...
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
print(f"{name!r} has been imported")
+ else:
+ print(f"can't find the {name!r} module")
Importing a source file directly