]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40552 Add 'users' variable in code sample (tutorial 4.2). (GH-19992)
authorAntoine <43954001+awecx@users.noreply.github.com>
Sat, 23 May 2020 00:29:34 +0000 (02:29 +0200)
committerGitHub <noreply@github.com>
Sat, 23 May 2020 00:29:34 +0000 (21:29 -0300)
* Add 'users' variable in code sample.

* ðŸ“œðŸ¤– Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Doc/tutorial/controlflow.rst
Misc/NEWS.d/next/Documentation/2020-05-09-12-10-31.bpo-40552._0uB73.rst [new file with mode: 0644]

index f05f5edd5ccc409cd210c0e0fa3c4c2c34b62a34..26de866aab90cbe105867400830c5e84fa23521d 100644 (file)
@@ -70,6 +70,9 @@ Code that modifies a collection while iterating over that same collection can
 be tricky to get right.  Instead, it is usually more straight-forward to loop
 over a copy of the collection or to create a new collection::
 
+    # Create a sample collection
+    users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}
+
     # Strategy:  Iterate over a copy
     for user, status in users.copy().items():
         if status == 'inactive':
diff --git a/Misc/NEWS.d/next/Documentation/2020-05-09-12-10-31.bpo-40552._0uB73.rst b/Misc/NEWS.d/next/Documentation/2020-05-09-12-10-31.bpo-40552._0uB73.rst
new file mode 100644 (file)
index 0000000..5ed9c31
--- /dev/null
@@ -0,0 +1,2 @@
+Fix in tutorial section 4.2.\r
+Code snippet is now correct.
\ No newline at end of file