https://github.com/python/cpython/commit/c8799f137a90f8fdfff4439969c09d85ef4bb8b0
commit: c8799f137a90f8fdfff4439969c09d85ef4bb8b0
branch: main
author: ByteFlow <[email protected]>
committer: hugovk <[email protected]>
date: 2026-04-28T08:08:23+03:00
summary:

gh-149035: Modernize legacy Python patterns in `Doc/tutorial/stdlib2.rst` 
(#149036)

Co-authored-by: Copilot <[email protected]>

files:
M Doc/tutorial/stdlib2.rst

diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index 678b71c9274c1c..6c68ba01081379 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -1,7 +1,7 @@
 .. _tut-brieftourtwo:
 
 **********************************************
-Brief Tour of the Standard Library --- Part II
+Brief tour of the standard library --- part II
 **********************************************
 
 This second tour covers more advanced modules that support professional
@@ -10,7 +10,7 @@ programming needs.  These modules rarely occur in small 
scripts.
 
 .. _tut-output-formatting:
 
-Output Formatting
+Output formatting
 =================
 
 The :mod:`reprlib` module provides a version of :func:`repr` customized for
@@ -130,7 +130,7 @@ templates for XML files, plain text reports, and HTML web 
reports.
 
 .. _tut-binary-formats:
 
-Working with Binary Data Record Layouts
+Working with binary data record layouts
 =======================================
 
 The :mod:`struct` module provides :func:`~struct.pack` and
@@ -178,14 +178,13 @@ tasks in background while the main program continues to 
run::
 
    class AsyncZip(threading.Thread):
        def __init__(self, infile, outfile):
-           threading.Thread.__init__(self)
+           super().__init__()
            self.infile = infile
            self.outfile = outfile
 
        def run(self):
-           f = zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED)
-           f.write(self.infile)
-           f.close()
+           with zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED) as f:
+               f.write(self.infile)
            print('Finished background zip of:', self.infile)
 
    background = AsyncZip('mydata.txt', 'myarchive.zip')
@@ -245,7 +244,7 @@ application.
 
 .. _tut-weak-references:
 
-Weak References
+Weak references
 ===============
 
 Python does automatic memory management (reference counting for most objects 
and
@@ -286,7 +285,7 @@ applications include caching objects that are expensive to 
create::
 
 .. _tut-list-tools:
 
-Tools for Working with Lists
+Tools for working with lists
 ============================
 
 Many data structure needs can be met with the built-in list type. However,
@@ -352,7 +351,7 @@ not want to run a full list sort::
 
 .. _tut-decimal-fp:
 
-Decimal Floating-Point Arithmetic
+Decimal floating-point arithmetic
 =================================
 
 The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to