Python 3.9 Features, Jupyter Black, and Anti-Patterns

·33m 24s
Shared point

Python 3.9 Feature Highlights

Python 3.9, with its final release scheduled for early October, introduces several long-awaited enhancements to the language:

Dictionary Merge/Update Operators: The new | (merge) and |= (update) operators provide a clean, consistent way to manipulate dictionaries.
String Methods: The inclusion of removeprefix() and removesuffix() simplifies string handling, replacing more complex and brittle workarounds.
Type Hinting Updates: Developers can now use built-in collection types like list and dict as generics directly, removing the need to import List or Dict from the typing module.
Enhanced Decorators: PEP 614 allows for more flexible decorator syntax, enabling any valid expression to be used as a decorator.
Standard Library: A new zoneinfo module has been added to support IANA time zone databases natively.

Tools for Jupyter and Development Safety

Formatting and Security

"There's no code is the best way to write secure and reliable applications. Write nothing, deploy nowhere."

Jupyter Black: This tool adds a toolbar button and keyboard shortcuts to auto-format Jupyter notebooks, bridging the gap between interactive notebooks and modern IDEs.
Denial of Service (DoS) Prevention: The discussion highlights the risk of Regex Denial of Service (ReDoS) and introduces DLint, a Flake8 plugin designed to detect security vulnerabilities during linting.

Advanced Topics and Community Engagement

Coding Patterns and Contributions

Visualizing Image Data: The bbox_visualizer project allows for easy creation of bounding boxes and labels on images, which is highly useful for computer vision and machine learning workflows.
Lambda Anti-Patterns: An exploration of how to use lambda expressions to create entire classes or even web applications, serving as a humorous warning on how to avoid extreme, unreadable code.
Effective Open Source: Vincent Wanderman discusses ways to contribute to popular projects without touching the complex core, such as improving error messages, adding CI testing for dependency shifts, and running spell checkers on docstrings.

Topics

Chapters

8 chapters
Python Bytes
AI chat — answers grounded in episodes