The http.server module is a convenient way to serve a directory over HTTP during development. Its responses carry a fixed set of headers describing the server, the date and the...
Help text produced by argparse often contains code fragments, such as file names, command lines and accepted values. Written in a sentence they blend into the surrounding words, so it...
A match statement can compare a value against number literals, and negative numbers have always been accepted, so case -1: is valid. A leading plus sign was not. Writing case...
The array module stores numbers in a fixed C type rather than as individual Python objects. The type code chosen when the array is created determines how many bytes each...
A task group runs several coroutines together and waits for all of them to finish. Sometimes that is more work than necessary. When a group asks several sources for the...
Decoding JSON produces Python objects chosen by the json module, and every JSON array becomes a list. That is a reasonable default, but a list is mutable and therefore cannot...
Many functions take an optional argument and need to know whether the caller supplied it. The simplest way is to give the argument a default of None and check for...
A command-line tool built with argparse rejects invalid values and lists the accepted ones, leaving users to spot typos themselves. Python 3.14 introduced suggestions for likely intended values, but enabling...
A bytearray can be modified after it is created, so it is a convenient place to collect data piece by piece. When the data is complete, it usually has to...
When an attribute lookup fails, Python tries to help by naming a likely candidate. The suggestion appears at the end of the error message as a "Did you mean" clause...