Python 3 Migrations, Walrus Operator, and CLI Tools
Automated Python Transitions
Transitioning codebases from Python 2 to 3 can be a daunting task for many organizations. The podcast highlights two efficient methods to assist in this process:
• Futurize: A modular, staged approach available at pythonfuture.org that provides granular control over code transformations.
• Auto-futurize: An innovative wrapper developed by Timothy Hopper that leverages Git and tox to automatically apply changes and verify that tests pass before committing, ensuring a safe conversion process.
Python 3.8 Features: The Walrus Operator
The episode dives into the controversial yet highly anticipated assignment expression, commonly known as the walrus operator (PEP 572). The hosts discuss its practical applications:
• It enables assignment within expressions, which is particularly beneficial for list comprehensions and dictionary lookups.
• This new syntax helps avoid redundant computations by allowing developers to assign a variable and use it immediately.
Improving CLI Experiences
The hosts discuss modern tools designed to improve the command-line interface (CLI) for Python applications:
• Bullet: An incredible library that adds interactive features to CLI applications, such as drop-down selections, password masking with stars, and color support, moving beyond basic input functions.
• pipx: An essential tool for installing and running Python application packages in isolated environments, perfect for utilities like PyJokes.
Async and GUI Development
The discussion shifts to managing concurrency in graphical user interfaces (GUIs):
• wxAsync: Merges the asyncio event loop with the WX Python library, preventing GUI freezes during background tasks.
• Unsync: A library that provides a unified API for multiprocessing, threading, and async methods, helping developers manage the complexity of asynchronous programming without the "viral" spread of async/await code.
"There are two ways to write error-free programs. Only the third one works."