As Python grows, the problem spaces we address keep shifting, and best practices for software development mature, so does the set of best-of-breed patterns and idioms change: some classics fading, new stars emerging. This talk helps fill the gap between yesterday’s good old Python, and tomorrow’s glittering vistas.
Python itself has grown to encompass some classic idioms, such as Decorate-Sort-Undecorate, AKA DSU, begetting the widespread key= argument to most functions related to ordering – but not quite all of them: heapq, for example, still mostly lacks key= – so, we also show what idioms to use with this and similar modules.
Lists have long been one of Python’s strengths, and they’re of course still precious – but many kinds of specialized containers have emerged, and it’s important to know how to choose among them, and when and how to roll your own. More important still, iterators have grown into prominence, and very often they’ll be the best choice – and they come with a large set of relevant patterns and idioms.
The tectonic shift that’s taking us from classic to modern Python goes even deeper – even the dominance of good old duck typing is threatened! Specifically, in many cases, we use, instead, goose typing – checking against an abstract base class – and, as type annotations slowly emerge, they reinforce this general tendency.
These, and a miscellanea of smaller patterns and idioms (concerning I/O, best uses of dicts and other specialized mappings, async operations, testing, …), are fast becoming indispensable parts of the Proficient Pythonista’s repertoire.