The Real Python Podcast

Real Python
undefined
Jan 6, 2023 • 45min

Surveying Comprehension Constructs & Python Parallelism Infighting

Have you embraced the use of comprehensions in your Python journey? Are you familiar with all the varieties of comprehension constructs? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder’s Weekly articles and projects. We discuss a recent article that surveys Python’s comprehensions and generators. This overview includes code snippets and the fundamentals of creating list, set, and dictionary comprehensions. We weigh the advantages of using a comprehension versus the more familiar for loops that they replace. Christopher shares an article about how there may be infighting between the parallelism in your Python code and the parallelism within the libraries that you’re using. These complex system interactions can cause processing slowdowns and hard-to-trace bottlenecks. We share several other articles and projects from the Python community, including a news roundup, a Python linter comparison, an overview of multiprocessing race conditions in Python, a discussion covering import statement styles, a project for WASM-powered Jupyter tools running in the browser, and a collection of easter eggs and jokes hidden inside Python itself. Course Spotlight: Understanding Python List Comprehensions Python list comprehensions make it easy to create lists while performing sophisticated filtering, mapping, and conditional logic on their members. In this course, you’ll learn when to use list comprehensions in Python and how to create them effectively. Topics: 00:00:00 – Introduction 00:02:41 – PyPy v7.3.10 Release 00:03:17 – Django Bugfix Release: 4.1.4 00:03:28 – Python 3.11.1, 3.10.9, 3.9.16, 3.8.16, 3.7.16 Released 00:03:56 – Python Linter Comparison 2022 00:11:51 – Who Controls Parallelism? A Disagreement That Leads to Slower Code 00:15:58 – Sponsor: InfluxDB 00:16:47 – A Crash Course in Comprehensions and Generators 00:24:23 – Multiprocessing Race Conditions in Python 00:27:46 – Video Course Spotlight 00:28:55 – What Style of import Statement Do You Use? 00:36:54 – jupyterlite: WASM Powered Jupyter Running in the Browser 00:40:35 – python-easter-eggs: Easter Eggs and Hidden Jokes in Python 00:43:18 – PyCoder’s Weekly: Submit a Link 00:43:46 – Thanks and goodbye News: PyPy v7.3.10 Release Django Bugfix Release: 4.1.4 Python 3.11.1, 3.10.9, 3.9.16, 3.8.16, 3.7.16 Released Show Links: Python Linter Comparison 2022 – There are many linter choices for Python. This article covers a lot of them: Pylint, Pyflakes, Flake8, autopep8, Bandit, Prospector, Pylama, Pyroma, Black, Mypy, Radon, and mccabe. Who Controls Parallelism? A Disagreement That Leads to Slower Code – In complex systems, there may be a fight between the parallelism in your code vs the parallelism in the libraries that you’re using. This fight can cause things to slow down. This article shows some examples and explores what you can do about the issue. A Crash Course in Comprehensions and Generators – A great collection of code snippets that showcase the power and flexibility of list comprehensions, generators, and related constructs. Multiprocessing Race Conditions in Python – A race condition happens when parallel tasks attempt to execute code at the same time and the results are dependent on order of execution. Finding race conditions can be challenging. This article gives some hints as to how to find the different kinds of race conditions when coding with the multiprocessing module. Discussion: What Style of import Statement Do You Use? Using wildcard imports (from … import *) — Python Anti-Patterns documentation Python import: Advanced Techniques and Tips – Real Python Projects: jupyterlite: WASM Powered Jupyter Running in the Browser python-easter-eggs: Easter Eggs and Hidden Jokes in Python Additional Links: Episode #39: Generators, Coroutines, and Learning Python Through Exercises – The Real Python Podcast How to Use Generators and yield in Python – Real Python PyCoder’s Weekly: Submit a Link Level up your Python skills with our expert-led courses: Threading in Python Understanding Python List Comprehensions Python Generators 101 Support the podcast & join our community of Pythonistas
undefined
Dec 23, 2022 • 1h 16min

2022 Real Python Tutorial & Video Course Wrap Up

It’s been another year of changes at Real Python! The Real Python team has written, edited, curated, illustrated, and produced a mountain of Python material this year. We added some new members to the team, updated the site’s features, and created new styles of tutorials and video courses. Three members of the Real Python team join us this week, Kate Finegan, Geir Arne Hjelle, and Leodanis Pozo Ramos. We wanted to share a year-end wrap-up with tutorials, step-by-step projects, and video courses that showcase what our team created this year. Kate and Geir Arne help to shepherd articles through the multi-stage editing process. Along with the rest of the team, they make sure these resources impart crucial Python knowledge and provide a thorough didactic experience. Leodanis’ name has been featured many times on this podcast, and it was great to talk to him about writing tutorials and diving deep into the Pythonic details. We hope you enjoy this review! Programming note, there won’t be an episode next week, but we’ll be back in January and look forward to bringing you a year full of great guests, articles, and topics. Course Spotlight: Building Python Project Documentation With MkDocs In this video course, you’ll learn how to build professional documentation for a Python package using MkDocs and mkdocstrings. These tools allow you to generate nice-looking and modern documentation from Markdown files and, more importantly, from your code’s docstrings. Topics: 00:00:00 – Introduction 00:03:02 – Geir Arne and RP content direction 00:04:31 – Kate Finegan and editing tutorials 00:07:35 – Leodanis Pozo Ramos and writing tutorials 00:09:14 – Changes for Real Python in 2022 00:18:56 – Your Python Coding Environment on Windows 00:23:32 – Sponsor: TelemetryHub 00:24:16 – Why Is It Important to Close Files in Python? 00:28:40 – Python and TOML: New Best Friends 00:33:47 – Sneaky REST APIs With Django Ninja 00:36:24 – Manage Your To-Do Lists Using Python and Django 00:39:52 – Python Constants: Improve Your Code’s Maintainability 00:42:59 – Build Your Python Project Documentation With MkDocs 00:49:28 – Building a URL Shortener With FastAPI and Python 00:51:24 – Video Course Spotlight 00:52:40 – Image Processing With the Python Pillow Library 00:57:20 – Draw the Mandelbrot Set in Python 01:05:01 – Using Python’s pip to Manage Your Projects’ Dependencies 01:11:39 – Exploring Scopes and Closures in Python 01:14:49 – Thanks and goodbye Show Links: Your Python Coding Environment on Windows: Setup Guide Why Is It Important to Close Files in Python? Python and TOML: New Best Friends Sneaky REST APIs With Django Ninja – Video Course Manage Your To-Do Lists Using Python and Django Python Constants: Improve Your Code’s Maintainability Build Your Python Project Documentation With MkDocs Building a URL Shortener With FastAPI and Python – Video Course Image Processing With the Python Pillow Library Draw the Mandelbrot Set in Python Using Python’s pip to Manage Your Projects’ Dependencies Exploring Scopes and Closures in Python – Video Course Additional Links: Building Python Project Documentation With MkDocs – Video Course Build a URL Shortener With FastAPI and Python – Step-by-Step Tutorial Level up your Python skills with our expert-led courses: Building Python Project Documentation With MkDocs Sneaky REST APIs With Django Ninja Exploring Scopes and Closures in Python Support the podcast & join our community of Pythonistas
undefined
4 snips
Dec 16, 2022 • 1h

Start Using a Build System & Continuous Integration in Python

What advantages can a build system provide for a Python developer? What new skills are required when working with a team of developers? This week on the show, Benjy Weinberger from Toolchain is here to discuss the Pants build system and getting started with continuous integration (CI). Benjy is one of the core developers of the Pants build system. He talks about the software tools and processes that a build system simplifies. We discuss how an individual developer can take advantage of continuous integration. We also cover some of the expectations when moving into professional software development. Have you learned about or started to use tools like linters, code formatters, import sorters, type checkers, and packaging systems? A build system is designed to combine all of those tools into a simplified, one-step process to share your best code. Benjy explains concepts like implementing fine-grained invalidation, moving to a monorepo, and using a build system for data science projects. He also shares his tips for getting started with Pants and finding help within the community. Course Spotlight: Testing Your Code With pytest In this video course, you’ll learn how to take your testing to the next level with pytest. You’ll cover intermediate and advanced pytest features such as fixtures, marks, parameters, and plugins. With pytest, you can make your test suites fast, effective, and less painful to maintain. Topics: 00:00:00 – Introduction 00:03:19 – Working on Pants 00:05:24 – Background on Toolchain 00:08:26 – Individual developer using CI 00:11:04 – When did you start using these types of tools? 00:14:30 – Was the organization open to the development of CI tools? 00:15:45 – Having a foundation with Git 00:17:11 – Moving toward workflows 00:23:30 – Sponsor: InfluxDB 00:24:20 – What’s fine-grained invalidation? 00:29:32 – Setting up test coverage 00:33:07 – Moving into packaging and deployment 00:37:22 – Advantages of a monorepo 00:42:10 – Video Course Spotlight 00:43:36 – Reasons for deeper Python integration 00:47:40 – Using the build system with data science projects 00:52:21 – Getting started with Pants 00:55:47 – What are you excited about in the world of Python? 00:57:12 – What do you want to learn next? 00:58:41 – How can people follow your work online? 00:59:27 – Thanks and goodbye Show Links: Pants 2: The ergonomic build system GitHub - pantsbuild/pants: The Pantsbuild developer workflow system Toolchain Labs E387 Build All the Things with Pants Build System - Talk Python To Me Continuous Integration With Python: An Introduction – Real Python Introduction to Git and GitHub for Python Developers – Real Python Monorepo Explained pex - PyPI pantsbuild/example-python: An example repo to demonstrate Python support The Pants community Christopher Neugebauer - Presentation at PyCon 2022 Talk - Christopher Neugebauer: Fast and reproducible tests, packaging, and deploys with… - YouTube Rust Programming Language Benjy Weinberger (@benjy) / Twitter Pantsbuild (@pantsbuild) / Twitter Level up your Python skills with our expert-led courses: Continuous Integration With Python Testing Your Code With pytest Test-Driven Development With pytest Support the podcast & join our community of Pythonistas
undefined
Dec 9, 2022 • 54min

Package Python Code With pyproject.toml & Listing Files With pathlib

How do you start packaging your code with pyproject.toml? Would you like to join a conversation that gently walks you through setting up your Python projects to share? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder’s Weekly articles and projects. We discuss a recent code conversation featuring Real Python team members Ian Currie and Geir Arne Hjelle. The video dives into the officially sanctioned way to configure your project using a pyproject.toml file. We cover how this relatively new approach will help you package your code for use on your system or for sharing with others. Christopher shares a Real Python tutorial about using pathlib to get a list of all the files within a directory. We’re both fans of pathlib and how it simplifies working with file paths. The tutorial digs into methods to recursively list all directory contents or create a conditional listing. We share several other articles and projects from the Python community, including an explanation of Python bytecode, an argument for always using [closed, open) intervals, a discussion about building the monolith before microservices, a way to parse natural language time and date expressions, and a project for posting on Mastodon. Course Spotlight: Using Python’s pathlib Module In this video course, you’ll learn how to effectively work with file system paths in Python 3 using the pathlib module in the standard library. Topics: 00:00:00 – Introduction 00:02:30 – Always Use [closed, open) Intervals 00:07:05 – Everyday Project Packaging With pyproject.toml 00:15:38 – Sponsor: InfluxDB 00:16:27 – How to Get a List of All Files in a Directory With Python 00:20:37 – Python Bytecode Explained 00:29:39 – Video Course Spotlight 00:30:48 – Build the Modular Monolith First 00:44:34 – toot - PyPI 00:49:58 – quickadd: Parse Natural Language Time and Date Expressions 00:53:09 – Thanks and goodbye Show Links: Always Use [closed, open) Intervals – “Intervals or ranges pop-up everywhere in the programming world. The classic example is picking a start and end date, like you would when booking an AirBnB or a flight. Have you ever wondered why they are always implemented as [closed, open) as opposed to [closed, closed]?” Everyday Project Packaging With pyproject.toml – In this Code Conversation video course, you’ll learn how to package your everyday projects with pyproject.toml. Playing on the same team as the import system means you can call your project from anywhere, ensure consistent imports, and have one file that’ll work for many build systems. How to Get a List of All Files in a Directory With Python – In this tutorial, you’ll be examining a couple of methods to get a list of files and folders in a directory with Python. You’ll also use both methods to recursively list directory contents. Finally, you’ll examine a situation that pits one method against the other. Python Bytecode Explained – When a Python program is run, the interpreter first parses your code and checks for syntax errors, then it translates it into bytecode instructions. This article explains some of the features of Python bytecode. Discussion: Build the Modular Monolith First – “Even talking about building a monolith today, is a bit taboo. It is all about microservices at the moment, and has been for a few years. But they aren’t a silver bullet.” Coding samples in the article aren’t Python, but the architectural advice is cross-language. Microservices and the First Law of Distributed Objects “I’m convinced that one of the biggest architectural mistakes of the past decade was going full microservice” Jason Warner - Twitter Projects: toot - PyPI quickadd: Parse Natural Language Time and Date Expressions Additional Links: Packaging Your Python Code With pyproject.toml | Complete Code Conversation - YouTube How to Publish an Open-Source Python Package to PyPI – Real Python Publishing Python Packages: Test, share, and automate your projects | Dane Hillard Episode #83: Ready to Publish Your Python Packages? – The Real Python Podcast Advanced Course on Python3 - MoserMichael - GitHub pyasmtool: Explores the Python bytecode, provides some tools to access it for fun and profit. - GitHub Episode #39: Generators, Coroutines, and Learning Python Through Exercises – The Real Python Podcast Episode #47: Unraveling Python’s Syntax to Its Core With Brett Cannon – The Real Python Podcast MVPy: Minimum Viable Python Episode #124: Exploring Recursion in Python With Al Sweigart – The Real Python Podcast Microservices and the First Law of Distributed Objects Mastodon for Python Devs - Talk Python #390 Mastodon is just blogs ActivityPub The Top 239 Activitypub Open Source Projects A 🦣 opportunity for developers - DEV Community 👩‍💻👨‍💻 Getting Started with Mastodon API in Python | Martin Heinz - Medium Christopher Trudeau (@cltrudeau) - Twitter Christopher Bailey | (@digiglean) - Twitter Christopher Bailey (@digiglean@fosstodon.org) - Fosstodon Real Python (@realpython@fosstodon.org) - Fosstodon Level up your Python skills with our expert-led courses: Lists and Tuples in Python Everyday Project Packaging With pyproject.toml Using Python's pathlib Module Support the podcast & join our community of Pythonistas
undefined
5 snips
Dec 2, 2022 • 58min

Preparing Data to Measure True Machine Learning Model Performance

How do you prepare a dataset for machine learning (ML)? How do you go beyond cleaning the data and move toward measuring how the model performs? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, returns to talk about strategies for better ML model performance. Jodie starts by defining some terms for the conversation. We talk about targets, features, and supervised learning. We discuss three common ways that data can alter model performance and which Python tools can help spot and avoid them. Jodie shares personal experiences of working through these pitfalls. We also share a healthy collection of resources to explore and learn more. Course Spotlight: Combining Data in pandas With concat() and merge() In this video course, you’ll learn two techniques for combining data in pandas: merge() and concat(). Combining Series and DataFrame objects in pandas is a powerful way to gain new insights into your data. Topics: 00:00:00 – Introduction 00:01:46 – Recent conference talks 00:03:24 – How to prepare your data for model performance 00:04:24 – Vocabulary: target, features, and supervised learning 00:06:28 – The curse of dimensionality 00:08:57 – Overfitting 00:11:08 – Underfitting 00:12:11 – Splitting the dataset 00:13:39 – K-fold cross validation 00:18:30 – Data leakage 00:21:36 – Checking for duplicates 00:26:23 – Applying transformations only after splitting data 00:31:16 – Imbalanced data 00:36:36 – Using ML to balance data 00:41:05 – Informing your model of the imbalance 00:42:56 – Video Course Spotlight 00:44:20 – Accuracy used as a measure 00:49:05 – Scikit-learn method classification_table 00:50:43 – Jet Brains blog post and conference talk 00:52:18 – How can people follow your work online? 00:54:39 – Upcoming webinars 00:56:20 – Thanks and goodbye Show Links: How to Prepare Your Dataset for Machine Learning and Analysis - The JetBrains Datalore Blog Curse of dimensionality - Wikipedia Overfitting vs. Underfitting: A Complete Example - Will Koehrsen A Gentle Introduction to k-fold Cross-Validation - MachineLearningMastery.com sklearn.model_selection.train_test_split — scikit-learn documentation Cross-validation: evaluating estimator performance — scikit-learn documentation sklearn.model_selection.cross_val_score — scikit-learn documentation Data Leakage And Its Effect On The Performance of An ML Model pandas.DataFrame.duplicated — pandas documentation pandas GroupBy: Your Guide to Grouping Data in Python – Real Python pandas.DataFrame.groupby — pandas documentation Difference between fit(), transform() and fit_transform() method in Scikit-learn - Aishwarya Chand: Nerd For Tech Imbalanced Data in Machine Learning - Google Developers Under-sampling — imbalanced-learn.org Over-sampling — imbalanced-learn.org Learn - Getting Started with Gretel.ai Classification on imbalanced data: Class weights - TensorFlow Core Tour of Evaluation Metrics for Imbalanced Classification - MachineLearningMastery.com CloudBrew - A two-day conference by AZUG, the Belgium Microsoft Azure User Group Jodie Burchell’s Blog - Standard error Jodie Burchell 🇦🇺🇩🇪 (@t_redactyl) - Twitter Jodie Burchell 🇦🇺🇩🇪 (@t_redactyl@fosstodon.org) - Fosstodon JetBrains: Essential tools for software developers and teams Level up your Python skills with our expert-led courses: Data Cleaning With pandas and NumPy Sneaky REST APIs With Django Ninja Combining Data in pandas With concat() and merge() Support the podcast & join our community of Pythonistas
undefined
24 snips
Nov 25, 2022 • 58min

Building Python REST APIs With Flask & Structuring Pull Requests

How do you build a REST API using the Flask web framework? How can you quickly add endpoints while automatically generating documentation? This week on the show, Real Python author Philipp Acsany is here to discuss his tutorial series “Python REST APIs With Flask, Connexion, and SQLAlchemy.” Christopher Trudeau is also here with another batch of PyCoder’s Weekly articles and projects. Philipp talks about updating a set of tutorials to use current libraries and best practices. The series takes you through building the base Flask project, defining endpoints, creating documentation, adding a persistent database, and implementing models with SQLAlchemy. Christopher shares an article about contributing to an existing internal or open-source project by properly preparing pull requests. The article is titled “Ten Tasty Ingredients for a Delicious Pull Request”. We share several other articles and projects from the Python community, including more suspicious PyPI packages using new tactics, method chaining in pandas, tools to find syntax errors without stopping, a library for searching text in videos using optical character recognition (OCR), a project for visualizing CPython’s specializing adaptive interpreter, and a library for building CLI applications based on type hints. Course Spotlight: The Pandas DataFrame: Working With Data Efficiently In this course, you’ll get started with pandas DataFrames, which are powerful and widely used two-dimensional data structures. You’ll learn how to perform basic operations with data, handle missing values, work with time-series data, and visualize data from a pandas DataFrame. Topics: 00:00:00 – Introduction 00:03:09 – Philipp’s background 00:05:37 – Python REST APIs With Flask, Connexion, and SQLAlchemy 00:14:35 – Ten Tasty Ingredients for a Delicious Pull Request 00:24:25 – Sponsor: InfluxDB 00:25:13 – Method Chaining in Pandas: Bad Form or a Recipe for Success? 00:31:35 – More Suspicious PyPI Packages 00:35:48 – Video Course Spotlight 00:37:01 – What Tools Find Syntax Errors Without Stopping? 00:47:29 – Perform OCR upon entire videos 00:49:49 – Visualize CPython 3.11’s Specializing, Adaptive Interpreter 00:54:08 – Typer, build great CLIs 00:56:29 – Thanks and goodbye Show Links: About Philipp Acsany – Real Python Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 1 Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 2 Python REST APIs With Flask, Connexion, and SQLAlchemy – Part 3 Ten Tasty Ingredients for a Delicious Pull Request – LB is a core team member of the open-source project Wagtail and, as such, has a lot of experience dealing with community contributions. This article talks about how to be a good contributor, whether for your next open-source software (OSS) PR or within your own organization. Method Chaining in Pandas: Bad Form or a Recipe for Success? – Python trainer Matt Harrison has been creating a bit of a stir. Some of his pandas examples have elicited criticism from different folks in the Twitterverse. Dave Amos interviews Matt to discuss the pros and cons of his approach. More Suspicious PyPI Packages – Researchers at Phylum have come across over a dozen new malicious uploads to PyPI. Many of them are copied and pasted versions of legitimate packages that have been renamed and had malicious code inserted. This detailed article shows some of the tactics used by the bad actors. Discussion: What Tools Find Syntax Errors Without Stopping? Projects: videocr: Perform OCR upon entire videos to look for credentials or similar Visualize CPython 3.11’s Specializing, Adaptive Interpreter Typer, build great CLIs Additional Links: What Percentage Of Websites Use WordPress In 2022? “Here’s a recipe to clean up the Ames housing dataset.” Matt Harrison - Twitter Idiomatic Pandas - Matt Harrison | Conf42 Python 2021 - YouTube Episode #103: Becoming More Effective at Manipulating Data With Pandas – The Real Python Podcast Getting started - Polars - User Guide py_compile — Compile Python source files — Python 3.11.0 documentation Build a Command-Line To-Do App With Python and Typer – Real Python Level up your Python skills with our expert-led courses: Deploy Your Python Script on the Web With Flask The pandas DataFrame: Working With Data Efficiently SQLite and SQLAlchemy in Python: Moving Your Data Beyond Flat Files Support the podcast & join our community of Pythonistas
undefined
Nov 18, 2022 • 45min

Moving Projects Away From Passwords With WebAuthn and Python

What if you didn’t have to worry about managing user passwords as a Python developer? That’s where the WebAuthn protocol and new hardware standards are heading. This week on the show, Dan Moore from FusionAuth returns to discuss a password-less future. WebAuthn is a way to authenticate users using biometric, secure authentication methods. Dan dives into passkeys, ceremonies, authenticators, and hardware standards. We also cover several projects and libraries that can help you get started with WebAuthn in Python. Course Spotlight: Refactoring: Prepare Your Code to Get Help In this Code Conversation video course, you’ll explore the steps you can take to get help when you’re stuck while coding. You’ll investigate how to clean up your code to focus on the question you have. Along the way, you’ll learn how to handle errors and use custom exceptions. Topics: 00:00:00 – Introduction 00:01:36 – Dan’s WebAuthn article 00:03:26 – FIDO and WebAuthn 00:05:53 – What’s a YubiKey? 00:07:57 – Phones with biometric systems 00:12:03 – Sponsor: CData Software 00:12:45 – Similarities to HTTPS 00:16:13 – A password-less future 00:24:31 – Where’s it being used? 00:30:53 – Video Course Spotlight 00:32:26 – Python WebAuthn projects and packages 00:34:52 – Does a developer need to set up additional auth methods? 00:37:31 – How are the third-party auth services implementing this? 00:39:50 – What are you excited about in the world of Python? 00:41:24 – What do you want to learn next? 00:43:20 – Thanks and goodbye Show Links: WebAuthn Explained - FusionAuth Episode #99: OAuth 2 and Authentication Choices for Your Python Project – The Real Python Podcast All about FIDO2, CTAP2 and WebAuthn - Microsoft Community Hub YubiKey - Hardware Security Keys Apple Adopts Passwordless Authentication Technology – Hideez 1Password is launching passkey support in early 2023 - The Verge duo-labs/py_webauthn: Pythonic WebAuthn python-webauthn: Server side handlers for WebAuthN with support for Apple’s FaceID, and the FIDO metadata service pywarp - PyPI webauthn-rp documentation Going Passwordless With py_webauthn - Duo Security django-webauth: Two Factor Authentication in Django using Web Authentication API (WebAuthn) django-webauthin - PyPI python-fido2 Python 3.11.0 Release - Python.org Real Food Fermentation by Alex Lewin - Amazon Auth. Built for Devs, by Devs - FusionAuth Level up your Python skills with our expert-led courses: Exploring HTTPS and Cryptography in Python Python Basics: Finding and Fixing Code Bugs Refactoring: Prepare Your Code to Get Help Support the podcast & join our community of Pythonistas
undefined
Nov 11, 2022 • 54min

Creating Tic-Tac-Toe With an AI Player & Shortcuts for Python Decorators

How do you create a computer opponent for a simple game within Python? Would you also like to learn how to adapt the game to run in a web browser or graphical user interface (GUI)? This week on the show, Christopher Trudeau is here, bringing another batch of PyCoder’s Weekly articles and projects. Christopher shares a recent Real Python step-by-step project for creating a tic-tac-toe game engine. He talks about how to build the game engine and adapt it for different front ends. The tutorial also shows how to implement an unbeatable computer player using the minimax algorithm. We discuss an article about how to avoid repeating yourself when creating decorators with multiple parameters. We talk about how you can stop copying and pasting code several times by assigning the decorator to a new variable. We share several other articles and projects from the Python community, including a news roundup, a deep dive into Python’s doctest, several Python command line tricks, type annotations via automated refactoring, a new way to draw boxes in the terminal, a collection of projects for beginners with source code, a minimalist PDF creation library, and a tool for sensible logging in Python. Course Spotlight: Python Decorators 101 In this course on Python decorators, you’ll learn what they are and how to create and use them. Decorators provide a simple syntax for calling higher-order functions in Python. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it. Topics: 00:00:00 – Introduction 00:02:25 – Python 3.12.0 Alpha 1 Released 00:02:45 – PyCon US 2023 Call for Proposals 00:03:27 – Python’s doctest: Document and Test Your Code at Once 00:13:59 – Build a Tic-Tac-Toe Game Engine With an AI Player in Python 00:22:12 – Sponsor: InfluxDB 00:22:59 – Python Command Line Tricks 00:30:50 – Type Annotation via Automated Refactoring 00:34:29 – A New (?) Way of Drawing Boxes in the Terminal 00:37:10 – Decorator Shortcuts 00:39:36 – Video Course Spotlight 00:41:02 – 190 Python Projects With Source Code 00:47:58 – fpdf2: Minimalist PDF Creation Library 00:50:04 – Simple, Sane, and Sensible Logging in Python 00:53:05 – Thanks and goodbye News: Python 3.12.0 Alpha 1 Released PyCon US 2023 Call for Proposals Topics: Python’s doctest: Document and Test Your Code at Once – In this tutorial, you’ll learn how to add usage examples to your code’s documentation and docstrings and how to use these examples to test your code. To run your usage examples as automated tests, you’ll use Python’s doctest module from the standard library. Build a Tic-Tac-Toe Game Engine With an AI Player in Python – In this step-by-step tutorial, you’ll build a universal game engine in Python with tic-tac-toe rules and two computer players, including an unbeatable AI player using the minimax algorithm. You’ll also create a text-based graphical front end for your library and explore two alternative front ends. Python Command Line Tricks – Using python -m you can do all sorts of things from the command line, including starting a webserver, opening a browser, parsing JSON, compressing files, and much more. Type Annotation via Automated Refactoring – Jimmy’s team at Carta decided they wanted to add type annotations to their large codebase, but doing so manually would’ve taken a very long time. This post shows you how they built automated refactoring tools to add type annotations to their code. A New (?) Way of Drawing Boxes in the Terminal – With clever use of some of the Unicode border characters, you can build a better box around your text, without any color bleeding. Decorator Shortcuts – “When using many decorators in code, there’s a shortcut you can use if you find yourself repeating them. They can be assigned to a variable just like any other Python expression.” Discussion: 190 Python Projects With Source Code Projects: fpdf2: Minimalist PDF Creation Library Simple, Sane, and Sensible Logging in Python – Get started with logging in Python or deploy advanced, flexible loggers without the boilerplate code. Learn all about log2d, a third-party wrapper for the Python logging library. Additional Links: Build Your Python Project Documentation With MkDocs – Real Python Episode #97: Improving Your Django and Python Developer Experience – The Real Python Podcast Python’s zipapp: Build Executable Zip Applications – Real Python Episode #80: Make Your Python App Interactive With a Text User Interface (TUI) – The Real Python Podcast Episode #20: Building PDFs in Python with ReportLab – The Real Python Podcast Links for Documentation FPDF and Other Ports PFython/log2d - GitHub Level up your Python skills with our expert-led courses: How to Work With a PDF in Python Python Inner Functions Python Decorators 101 Support the podcast & join our community of Pythonistas
undefined
Nov 4, 2022 • 1h 2min

Exploring the New Features of Python 3.11

Python 3.11 is here! Our regular guests, Geir Arne Hjelle and Christopher Trudeau, return to talk about the new version. Geir Arne wrote a series of preview tutorials earlier this year, and his annual piece, titled “Python 3.11: Cool New Features for You to Try,” was published on October 24. Christopher’s video course came out the next day, covering the topics from the tutorial with visual examples of Python 3.11 in action. Geir Arne and Christopher collaborated to create code examples for the new features. We discuss better error messages, faster code execution, task and exception groups, typing features, and native TOML support. We dive into the updates and offer advice about ways to incorporate them into your projects. We also consider when you should start running Python 3.11. Course Spotlight: Cool New Features in Python 3.11 – Real Python In this video course, you’ll explore what Python 3.11 brings to the table. You’ll learn how Python 3.11 is the fastest and most user-friendly version of CPython yet, and learn about improvements to the typing system and to the asynchronous features of Python. Topics: 00:00:00 – Introduction 00:02:19 – Preview series 00:03:50 – Faster CPython project 00:07:10 – Specializing adaptive interpreter 00:11:24 – Other performance stuff 00:16:07 – Sponsor: Deepgram 00:16:51 – Improved tracebacks 00:21:49 – Exception groups and notes 00:27:22 – Self type and additional type hints 00:36:14 – Video Course Spotlight 00:37:27 – asyncio and task groups 00:41:25 – TOML and tomllib 00:46:21 – ISO date parsing 00:50:09 – Negative zeros 00:53:38 – Dead battery deprecations 00:56:04 – Advice on upgrading 01:01:01 – Thanks and goodbye Show Links: Python 3.11: Cool New Features for You to Try – Real Python Cool New Features in Python 3.11 – Video Course faster-cpython/plan.md - GitHub PEP 659 – Specializing Adaptive Interpreter - peps.python.org Just-in-time compilation - Wikipedia Episode #381 Python Perf: Specializing, Adaptive Interpreter - Talk Python To Me Podcast Episode #339 Making Python Faster with Guido and Mark - Talk Python To Me Podcast “Zero cost” exception handling · Issue #84403 · python/cpython - GitHub Python 3.11 Preview: Task and Exception Groups – Real Python Faster Startup In Python 3.11 — Python 3.11.0 documentation Python 3.11 Preview: Even Better Error Messages – Real Python PEP 657 – Include Fine Grained Error Locations in Tracebacks - peps.python.org Episode #105: Creating Better Error Messages for Python 3.10 & 3.11 – The Real Python Podcast Exception Groups and except: Irit Katriel - YouTube PEP 673 – Self Type - peps.python.org PEP 646 – Variadic Generics - peps.python.org How Exception Groups Will Improve Error Handling in AsyncIO - Łukasz Langa | Power IT Conference - YouTube Neopythonic: Reasoning about asyncio.Semaphore PEP 680 – tomllib: Support for Parsing TOML in the Standard Library - peps.python.org TOML: Tom’s Obvious Minimal Language Python 3.11 Preview: TOML and tomllib – Real Python datetime — Basic date and time types — Python 3.11.0 documentation 13 Month Calendar Signed zero - Wikipedia PEP 594 – Removing dead batteries from the standard library - peps.python.org Level up your Python skills with our expert-led courses: Cool New Features in Python 3.10 Cool New Features in Python 3.11 Python Type Checking Support the podcast & join our community of Pythonistas
undefined
Oct 21, 2022 • 1h 9min

Fostering an Internal Python Community & Managing the 3.11 Release

Does your company have a plan for growing an internal Python community? What are the attributes to look for when bringing someone into your department? This week on the show, Pablo Galindo Salgado returns to talk about building community through the Python Guild at Bloomberg and managing the release of Python 3.11. Pablo describes how the Python Guild started and currently operates inside Bloomberg. We talk about how it fosters community and acts as a way to promote internally developed tools across disparate teams. We also discuss how work groups use it to find new internal candidates for their teams. Pablo talks about his role as release manager for Python 3.10 and 3.11. He shares the intense journey the team has had this year in preparing for the release of 3.11. He details updating testing strategies to work with the new specializing adaptive interpreter. Course Spotlight: Python Basics: Strings and String Methods In Python, collections of text are called strings. In this course, you’ll learn about this fundamental data type and the string methods that you can use to manipulate strings. Along the way, you’ll learn ways to work with strings of numbers, and how to format strings for printing. Topics: 00:00:00 – Introduction 00:02:13 – Python Guild inside of Bloomberg 00:13:31 – Finding candidates for the guild from other areas 00:19:11 – Sponsor: Platform.sh 00:19:47 – Considering eagerness to learn and excitement 00:29:44 – Structuring the guild into work groups 00:33:43 – How are things going as release manager? 00:38:25 – Testing for adaptive interpreters 00:44:02 – Working toward the feature freeze 00:50:39 – Changing the parser went smoothly 00:54:34 – Video Course Spotlight 00:55:55 – Where do you find the time? 00:59:51 – How’s the sweep picking coming along? 01:00:33 – What are you excited about in the world of Python? 01:01:29 – What do you want to learn next? 01:07:18 – How can people follow the work you do? 01:08:20 – Thanks and goodbye Show Links: Bloomberg publishes Memray, a new open source memory profiler for Python code - Bloomberg LP bloomberg/memray: Memray is a memory profiler for Python Pluralsight Tech Blog - Guilds at Pluralsight Lessons From Building a Community of Python Users Among Capital One’s Analysts - Capital One PEP 13 – Python Language Governance - peps.python.org Python Insider: Python 3.11.0rc2 is now available What’s New In Python 3.11 — Python 3.11.0rc2 documentation PEP 659 – Specializing Adaptive Interpreter - peps.python.org Andon (manufacturing) - Wikipedia Learn Rust - Rust Programming Language Swift - Apple raywenderlich.com - High quality programming tutorials: iOS, Android, Swift, Kotlin, Flutter, Server Side Swift, Unity, and more! Python Developers Survey 2022 pablogsal (Pablo Galindo Salgado) - GitHub Pablo Galindo Salgado (@pyblogsal) - Twitter Level up your Python skills with our expert-led courses: Python Basics: Strings and String Methods Cool New Features in Python 3.10 Python Basics: Code Your First Python Program Support the podcast & join our community of Pythonistas

The AI-powered Podcast Player

Save insights by tapping your headphones, chat with episodes, discover the best highlights - and more!
App store bannerPlay store banner
Get the app