.. _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
.. _tut-output-formatting:
-Output Formatting
+Output formatting
=================
The :mod:`reprlib` module provides a version of :func:`repr` customized for
.. _tut-binary-formats:
-Working with Binary Data Record Layouts
+Working with binary data record layouts
=======================================
The :mod:`struct` module provides :func:`~struct.pack` and
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')
.. _tut-weak-references:
-Weak References
+Weak references
===============
Python does automatic memory management (reference counting for most objects and
.. _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,
.. _tut-decimal-fp:
-Decimal Floating-Point Arithmetic
+Decimal floating-point arithmetic
=================================
The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for