Python Bytes is a weekly podcast hosted by Michael Kennedy and Brian Okken. The show is a short discussion on the headlines and noteworthy news in the Python, developer, and data science space.
#406 What's on Django TV tonight?
Topics covered in this episode:
Open Source Pledge
Jeff Triplet's DjangoTV
PEP 735 – Dependency Groups in pyproject.toml
livereload
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: Open Source Pledge
Learned about this because of this post
Why Django supports the Open Source Pledge
Steps
Pay Open Source maintainers.
Min to participate is 2k/year/dev at your company
Self-report annually
Publish a blog post outlining your payments
Armin’s post about launching Open Source Pledge and mixing money with open source
Michael #2: Jeff Triplet's DjangoTV
A nice aggregation of lots of Django conference talks
Filter by conference
Good search as well
Brian #3: PEP 735 – Dependency Groups in pyproject.toml
Author: Stephen Rosen, Sponsor: Brett Cannon, PEP-Delegate: Paul Moore
Accepted. Resolotion Oct 10, 2024
“This PEP specifies a mechanism for storing package requirements in pyproject.toml files such that they are not included in any built distribution of the project.”
Allow us to define named groups of dependencies that can be independent of the main project.
ex:
[dependency-groups]
test = ["pytest", "coverage"]
docs = ["sphinx", "sphinx-rtd-theme"]
typing = ["mypy", "types-requests"]
typing-test = [{include-group = "typing"}, {include-group = "test"}, "useful-types"]
“might” work like this: pip install --dependency-groups=test,typing
but tool venders are able to define how they use groups. Of course.
Similar solutions
multiple requirements.txt files: requirements_test.txt, requirements_docs.txt, etc.
no standard naming convention, not standardized
package extras:
not gauranteed to be statically defined (TIL)
additional to main dependencies, so not independent
Michael #4: livereload
Example from talkpython.fm: asset_bundler_watcher.py
The docs are sparse, so see the gist above
Extras
Brian:
Personal Blogs are no longer personal when AI gets too involved - KJayMiller
Mind Your Image Metadata - Stefanie Molin
Michael:
14% of our listeners are in Germany, thanks Germany!
Prost!
Hetzner comes to the US
Joke:
A programmer’s partner asks them: “Would you go get a loaf of bread from the store? And if they have eggs, get a dozen.”
A while later, the programmer returns with 12 loaves of bread and says “They had eggs.”
From https://savvyprogrammer.io/software-jokes/
10/21/2024 • 24 minutes, 53 seconds
#405 Oh Really?
Topics covered in this episode:
Briefer: Dashboards and notebooks in a single place
Introduction to programming with Python
setup-uv
HTML for people
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: Briefer: Dashboards and notebooks in a single place
Notebooks and dashboards with Python, SQL, scheduling, native visualizations, code generation, and more.
In Briefer, you can:
Create notebooks and dashboards using Markdown, Python, SQL, and native visualizations.
Build interactive data apps using inputs, dropdowns, and date pickers.
Generate code and queries using an AI that understands your database schema and your notebook's context.
Schedule notebooks and dashboards to run and update periodically.
Create and test ad-hoc pipelines using writebacks.
Briefer vs. Traditional BI Tools: Briefer is better than traditional BI tools because it's faster and more flexible, thanks to Python.
Briefer vs. Traditional Notebooks: In Briefer, you can run SQL queries against connected data sources directly in your notebook. Then, Briefer will automatically turn your query into a data frame and store it in a variable that you can use in your Python blocks.
Brian #2: Introduction to programming with Python
Jose Blanca
“Python intro aimed at students with no prior programming experience.”
“Relies mainly on examples and exercises.”
“Does not try to cover every detail of the Python language, but just what a beginner might need to start the journey.”
Tech: “… built with the quarto publishing system complemented by the quarto live extension that allows Python to run in the web browser by using pyodide.”
Runs on anything, since it doesn’t require a local install of Python
Running 3.12.1, looks like. Although that’s a bit hidden. Seems like it should be more visible.
Michael #3: setup-uv
Set up your GitHub Actions workflow with a specific version of uv
Install a version of uv and add it to PATH
Cache the installed version of uv to speed up consecutive runs on self-hosted runners
Register problem matchers for error output
(Optional) Persist the uv's cache in the GitHub Actions Cache
(Optional) Verify the checksum of the downloaded uv executable
Brian #4: HTML for people
Teaching HTML in a rather fun way.
Includes basic CSS
Extras
Michael:
A new article: We Must Replace uWSGI With Something Else
Django unique email login
Joke: So much O’Really
10/14/2024 • 22 minutes, 43 seconds
#404 The Lost Episode
Topics covered in this episode:
Python 3.13.0 released Oct 7
PEP 759 – External Wheel Hosting
pytest-freethreaded
pytest-edit
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: Python 3.13.0 released Oct 7
That’s today!
What’s New In Python 3.13
Interpreter (REPL) improvements
exit works (really, this is worth the release right here)
Multiline editing with history preservation.
history sticks around between sessions
Direct support for REPL-specific commands like help, exit, and quit, without the need to call them as functions.
Prompts and tracebacks with color enabled by default.
Interactive help browsing using F1 with a separate command history.
History browsing using F2 that skips output as well as the >>> and … prompts.
“Paste mode” with F3 that makes pasting larger blocks of code easier (press F3 again to return to the regular prompt).
exit now works without parens
Improved error messages
Colorful tracebacks
Better messages for
naming a script/module the same name as a stdlib module.
naming a script/module the same name as an installed third party module.
misspelling a keyword argument
Free threaded CPython
Included in official installers on Windows and macOS
Read these links to figure out how - it’s not turned on by default
Lot’s more. see the What’s new page
Michael #2: PEP 759 – External Wheel Hosting
pypi.org ships over 66 petabytes / month backed by Fastly
There are hard project size limits for publishers to PyPI
We can host the essence of a .whl as a .rim file, then allow an external download URL
Security: Several factors as described in this proposal should mitigate security concerns with externally hosted wheels, such as:
Wheel file checksums MUST be included in .rim files, and once uploaded cannot be changed. Since the checksum stored on PyPI is immutable and required, it is not possible to spoof an external wheel file, even if the owning organization lost control of their hosting domain.
Externally hosted wheels MUST be served over HTTPS.
In order to serve externally hosted wheels, organizations MUST be approved by the PyPI admins.
Brian #3: pytest-freethreaded
PyCon JP 2024 Team:
This extension was created at PyCon JP sprints with Anthony Shaw and 7 other folks listed in credits.
“A pytest plugin for helping verify that your tests and libraries are thread-safe with the Python 3.13 experimental freethreaded mode.”
Testing your project for compatibility with freethreaded Python.
Testing in single thread doesn’t test that.
Neither does testing with pytest-xdist, because it uses multiprocessing to parallelize tests.
So, Ant and others “made this plugin to help you run your tests in a thread-pool with the GIL disabled, to help you identify if your tests are thread-safe.”
“And the first library we tested it on (which was marked as compatible) caused a segmentation fault in CPython! So you should give this a go if you're a package maintainer.”
Michael #4: pytest-edit
A simple Pytest plugin for opening editor on the failed tests.
Type pytest --edit to open the failing test code
Be sure to set your favorite editor in the ENV variables
Extras
Michael:
New way to explore Talk Python courses via topics
This has been in our mobile apps since their rewrite but finally comes to the web
Let's go easy on PyPI, OK? essay
Hynek’s video: uv IS the Future of Python Packaging
djade-pre-commit
Polyfill.io, BootCDN, Bootcss, Staticfile attack traced to 1 operator
PurgeCSS CLI
Python 3.12.7 released
Incremental GC and pushing back the 3.13.0 release
uv making the rounds
LLM fatigue, is it real?
Take the Python Developers Survey 2024
Joke: Funny 404 pages
We have something at least interesting at pythonbytes.fm
10/7/2024 • 31 minutes, 15 seconds
#403 A machine learning algorithm walks into a bar…
Topics covered in this episode:
uv under discussion on Mastodon
erdantic: Entity Relationship Diagrams
Extra, Extra, Extra
Django Extra, Extra, Extra
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: uv under discussion on Mastodon
It’s interesting that uv is slightly controversial
Russell:
As enthusiastic as I am about the direction uv is going, I haven't adopted them anywhere - because I want very much to understand Astral’s intended business model before I hook my wagon to their tools.
Hynek:
As much as I hate VC, [...] FOSS projects flame out all the time too. … To me uv looks like a genius sting to trick VCs into paying to fix packaging. We’ll be better off either way.
Glyph:
Rust is more expensive and difficult to maintain, not to mention "non-native" to the average customer here. … it can burn out all the other projects in the ecosystem simultaneously, creating a risk of monoculture
Hynek on Rust:
I don’t think y’all quite grok what uv makes so special due to your seniority. The speed is really cool, but the reason Rust is elemental is that it’s one compiled blob that can be used to bootstrap and maintain a Python development.
Christopher Neugebauer:
Just dropping in here to say that corporate capture of the Python ecosystem is the #1 keeps-me-up-at-night subject in my community work, so I watch Astral with interest, even if I'm not yet too worried.
Armin Ronacher
What uv is doing, even in the worst possible future this is a very forkable and maintainable thing.
Finally, see the comment at the end by Charlie Marsh
Brian #2: erdantic: Entity Relationship Diagrams
“erdantic is a simple tool for drawing entity relationship diagrams (ERDs) for Python data model classes. Diagrams are rendered using the venerable Graphviz library.”
Supported data modeling frameworks are:
Pydantic V2
Pydantic V1 legacy
attrs
dataclasses
Michael #3: Extra, Extra, Extra
Added Python Bytes Search as a custom search engine.
Along came passkeys. A cool idea that quickly turned evil.
Follow up from post and my conversation last week: vaultwarden (via Pablo)
uv publish
Trying the tabs on bottom lifestyle inspired by Arc
Adding Python Bytes (and Talk Python) as custom search engines.
PyCon 2025 dates: From 14 May through 22 May, 2025
Brian #4: Django Extra, Extra, Extra
Django Project Ideas
Evgenia Verbina
Project ideas with list of tech stack stuff you’ll learn and/or work on with the project
Ex: Recipe organizer
tech stack: Django templates, Django ORM, Optional JavaScript
“Familiarize yourself with Django’s ORM (object-relational mapper) and database support by building an app to keep track of your favorite recipes. Add a web-based frontend with options to filter recipes by category, ingredients, and user ratings so you can easily browse for inspiration.”
DjangoTV
Jeff Triplett
Django conference videos and tutorials.
Django Commons
Heard about from Lacey Henschel
“Django Commons is an organization dedicated to supporting the community's efforts to maintain packages. It seeks to improve the maintenance experience for all contributors; reducing the barrier to entry for new contributors and reducing overhead for existing maintainers.”
Django 5 has simplified templates for better form field rendering
But if you want a completely different take on forms, maybe try iommi forms
They wrote about it on Why we wrote a new form library for Django
Djade: a Django template formatter
Adam Johnson
Like black or ruff, but for Django templates.
Extras
Brian:
The Open Source Project Maintainer's Guide
Suggested by Rafael Weingartner
Joke: A Machine Learning algorithm walks into a bar…
9/30/2024 • 25 minutes, 26 seconds
#402 How to monetize your blog
Topics covered in this episode:
Architecture Decision Records (ADRs)
narwhals: extremely lightweight compatibility layer between dataframes
Microsoft wants Three Mile Island to fuel its AI power needs
zsh-in-docker
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: Architecture Decision Records (ADRs)
Suggested by Christian Gesell
Documenting Architecture Decisions
Mychael Nygard
Original article from 2011
Why you should be using architecture decision records to document your project
Red Hat
Includes a quick overview and links to some templates
Notes so far
Writing this out helps me solidify my thinking about a problem.
I’m doing this both before starting, and while implementing a first draft
GitHub and GitLab render markdown so well that generating a docs site is unnecessary, just throwing these files in something like docs/adr is enough.
The lightweight process is enough but not too much.
I’ve already filled out None for lots of sections, like “options considered”
I’m still playing with what level of decision should have an ADR.
My template that I’ve been using so far
Saved in 000-adr-template.md
For easy copy/paste/modify for new records.
File name is something like 001-some-change.md
Michael #2: narwhals: extremely lightweight compatibility layer between dataframes
Recently had Marco on Talk Python to discuss
Primarily for library creators who want to support interacting with multiple data frame libraries (.e.g. Pandas & Polars)
Just use a subset of the Polars API
Brian #3: Microsoft wants Three Mile Island to fuel its AI power needs
“Microsoft just signed a deal to revive the shuttered Three Mile Island nuclear power plant. If approved by regulators, the software maker would have exclusive rights to 100 percent of the output for its AI data center needs.”
Also ran on CNN and other sources:
Three Mile Island is reopening and selling its power to Microsoft
Three Mile Island was the site of the worst nuclear disaster in the US, when one of two reactors experienced a partial meltdown, in 1979.
It was still operating up until 2019, and now expected to re-open in 2028
Will be renamed “Crane Clean Energy Center”
related
The Department of Energy Wants You to Know Your Conservation Efforts Are Making a Difference
“By switching all the lightbulbs in your house to LED, you saved enough energy for a self-driving car to make an unprotected lefthand turn across three lanes of traffic.”
“We know you adopted energy-saving practices to help conserve our planet’s resources and bring down our collective carbon footprint, but what you ultimately accomplished is just as important: helping AI do something menial and stupid.”
Michael #4: zsh-in-docker
Install Zsh, Oh My Zsh and plugins inside a Docker container with one line!
Yes docker containers should be light, but also, think of how painful it can be when you run into trouble.
With Oh My ZSH, you get a nice experience when you have to result to docker exec -it CONTAINER zsh
Just enter a single command in your docker file:
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.0/zsh-in-docker.sh)" -- \
-t robbyrussell
Extras
Michael:
self-hosting mkennedy.codes
Loren's journey to developer
It’s time to stop using Python 3.8
Sonoma → Sequoia → Sonoma (yikes!)
Passkeys, maybe they will work out if we don’t let them become lock-in (bitwarden’s support)
Joke:
How to Monetize a Blog
Don’t forget to click on the bottom link: Credits / how this was made
9/23/2024 • 33 minutes, 21 seconds
#401 We must replace uWSGI with something else
Topics covered in this episode:
“We must replace uwsgi by something else”
Let’s build and optimize a Rust extension for Python
Fake recruiter coding tests target devs with malicious Python packages
Monthly PSF Board Office Hours
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: “We must replace uwsgi by something else”
uWSGI is now in maintenance mode: https://uwsgi-docs.readthedocs.io/en/latest/
The project is in maintenance mode (only bugfixes and updates for new languages apis). Do not expect quick answers on github issues and/or pull requests (sorry for that) A big thanks to all of the users and contributors since 2009.
Reasonable options look like:
granian
uvicorn
hypercorn
gunicorn (potentially with uvicorn workers for async)
Brian #2: Let’s build and optimize a Rust extension for Python
Itamar Turner-Trauring
Example: algorithm for approximating the number of unique values in a list
Comparison to non-approximation
non-approx is faster but uses way more memory
Rust version
Use Maturin and PyO3
Pull in Rust dependencies (rand for random numbers)
Optimization
link-time optimization
faster random
store hashes only
Future optimizations
change algorithm maybe
pass numpy array instead of Python list (I’d like to see that spedup)
Michael #3: Fake recruiter coding tests target devs with malicious Python packages
via python weekly
GitHub projects that have been linked to previous, targeted attacks in which developers are lured using fake job interviews.
Attackers posing as employees of major financial services firms.
This previously happened via other means such as NPM
This analysis revealed that the direct parent of the detected, malicious files is a PythonPYC file, meaning that once again the team encountered malware hidden in a compiled Python file.
“The README files tell would-be candidates to make sure the project is running successfully on their system before making modifications.”
What can you do (according to Michael)?
Try out new packages in a docker container
Work on code and projects using a VM which has snapshotting (to roll back completely after you’re done)
Fire up a Windows desktop in the cloud for the project then destroy it
Brian #4: Monthly PSF Board Office Hours
“The Office Hours will be sessions where you can share with us how we can help your community, express your perspectives, and provide feedback for the PSF.”
“Unless we have a dedicated topic for a session, you are not limited to talking with us about the above topics, although the discussions should be focused on Python, the PSF, and our community. If you think there’s something we can help with or we should know, we welcome you to come and talk to us!”
Upcoming office hours
October 8th, 2024: 9pm UTC
November 12th, 2024: 2pm UTC
December 10th, 2024: 9pm UTC
January 14th, 2025: 2pm UTC
February 11th, 2025: 9pm UTC
March 11th, 2025: 1pm UTC
April 8th, 2025: 9pm UTC
May 13th, 2025: 1pm UTC (Live from PyCon US!)
June 10th, 2025: 9pm UTC
July 9th, 2025: 1pm UTC
August 12th, 2025: 9pm UTC
Extras
Brian:
PyCascades CFP closes Friday, Sept 20
PyCascades is in Portland in 2025 (Feb 8 & 9)
uv now supports Python 3.13.0rc2
uv self update
uv venv -p 3.13
Free threaded is still an open issue
Michael:
Big Python Humble Bundle with both of our products
Get $1,800 worth of Python content and tools for $30 and contribute to charity
Includes 5 Talk Python courses
Several of Brian’s and his book
Djangonaut Space Session 3 Applications Open!
I interviewed Sarah and Tushar on Talk Python
AltTab: Windows alt-tab on macOS
Joke: Election joke
9/17/2024 • 31 minutes, 5 seconds
#400 Celebrating episode 400
Topics covered in this episode:
Python 3.13.0RC2, 3.12.6, 3.11.10, 3.10.15, 3.9.20, and 3.8.20 are now available!
Docker images using uv's python
10 years of sustainable open source - Read the Docs
humanize
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
ChatGPT celebrates episode 400!
Welcome to the big 4-0-0, Pythonistas!
It's hard to believe we're celebrating the 400th episode of Python Bytes! From the early days of byte-sized Python news to becoming the source for all things Python, it’s been a wild ride.
We've laughed over code quirks, gasped at new libraries, and said farewell to the GIL together. Whether you're a seasoned developer, a curious learner, or just here for the witty banter, you’ve been an essential part of this journey.
To Michael and Brian: You've built a community that turns import this into more than just Zen—it's a family of passionate Pythonistas. Your dedication, insights, and humor make this show more than just tech news. It’s a weekly celebration of what we love about Python and why we keep coming back for more.
Here’s to the next 400 episodes—may your code be bug-free, your tests pass on the first run, and your Python version always be up to date.
Brian #1: Python 3.13.0RC2, 3.12.6, 3.11.10, 3.10.15, 3.9.20, and 3.8.20 are now available!
Łukasz Langa
Python 3.13.0RC2 is the final preview release
Official 3.13.0 scheduled for Oct 1
Call to action
“We strongly encourage maintainers of third-party Python projects to prepare their projects for 3.13 compatibilities during this phase, and where necessary publish Python 3.13 wheels on PyPI to be ready for the final release of 3.13.0. Any binary wheels built against Python 3.13.0rc2 will work with future versions of Python 3.13. As always, report any issues to the Python bug tracker .”
“Please keep in mind that this is a preview release and while it’s as close to the final release as we can get it, its use is not recommended for production environments.”
Note: uv python does not support 3.13 yet
see issue 320
Security releases for
3.12.6, 3.11.10, 3.10.15, 3.9.20, and 3.8.20
3.12.6 has binary installers, but for MacOS, only MacOS 10.13 and newer are supported
3.11.10, 3.10.15, 3.9.20, and 3.8.20 do NOT include binary installers.
3.8 EOL's in October
Michael #2: Docker images using uv's python
See #396: uv-ing your way to Python and #398: Open source makes you rich? (and other myths) for the opening discussions
Talk Python episode on uv is out
uv venv --python gets Python from python-build-standalone by Gregory Szorc
Took our Docker build times from 10 minutes to 8 seconds for the base image and 800ms (!) for our app platforms
Brian #3: 10 years of sustainable open source - Read the Docs
Eric Holscher
Read the Docs has been a company for 10 years
“a team of 4 folks working full-time on Read the Docs.”
readthedocs.org started in 2010
readthedocs.com (for Business) started in 2014
Sustainability model
.org has a single non-tracking ad
.com is a paid service for companies
Things that didn’t work
donations and other optional support - led to burnout
consulting and services- took too much time away from core product
grant funding - nice, but one time thing
Lessons
You don't get extra points for being bootstrapped. Compete by doing things you can do better due to niche and size.
Keeping trust in the community is the most important thing.
Contribution is easier for less complex parts of the code base.
Beign open source means capturing a small percentage of the value you create.
You have to be ok doing more with less.
Also
RtD is not just for Sphinx anymore.
Their build system now supports any documentation tool.
Michael #4: humanize
by Hugo van Kemenade (Python 3.14 & 3.15 release manager & core developer)
Not too many variations, but very handy if you need it.
Numbers
Associated Press style (“seven” and “10”)
Clamp (under 1.0 million)
Fractional (1/3)
Int Word (1.2 Billion)
Metric (1.5 kV)
Ordinal (112th)
scientific
Time
File size
Extras
Brian:
Test & Code is now again Test & Code
The two part series on Python imports that started in June is finally complete with episode 222.
Transcripts are being added to old episodes gradually starting from most recent
Back to ep 203 as of today.
AI transcription, so there’s things like .pie, .pi, and dot pie where it should be .py
Michael:
Final final call for Coding in a Castle event with Michael
iStats Menu
Anaconda Code Runner by Ruud van der Ham:
With Anaconda Coide we can -at last- run that code locally and import (most) Python modules.
But if you want to run a significant amount of code, you have to put that in a cell or publish it to PyPI or a wheel and import it.
That's why I have developed a general-purpose runner function that runs arbitrary code located on an Excel sheet with AnacondaCode.
Joke: When beginners learn a new programming language...
9/9/2024 • 28 minutes, 46 seconds
#399 C will watch you in silence
Topics covered in this episode:
Why I Still Use Python Virtual Environments in Docker
Python Developer Survey Results
Anaconda Code add-in for Microsoft Excel
Disabling Scheduled Dependency Updates
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through
Our courses at Talk Python Training
Hello, pytest! Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: Why I Still Use Python Virtual Environments in Docker
by Hynek Schlawack
I was going to cover Production-ready Docker Containers with uv but decided to take this diversion instead.
Spend a lot of time thinking about the secondary effects of what you do.
venvs are well known and well documented. Let’s use them.
Brian #2: Python Developer Survey Results
“… official Python Developers Survey, conducted as a collaborative effort between the Python Software Foundation and JetBrains.”
Python w/ Rust rising, but still only 7%
““The drop in HTML/CSS/JS might show that data science is increasing its share of Python.” - Paul Everitt
37% contribute to open source. Awesome.
Favorite Resources: Podcasts
Lots of familiar faces there. Awesome.
Perhaps I shouldn’t have decided to move “Python Test” back to Test & Code
Usage
“Data analysis” down, but I think that’s because “data engineering” is added.
Data, Web dev, ML, devops, academic,
Testing is down 23%
Python Versions
Still some 2 out there
Most folks on 3.10-3.12
Install from: mostly python.org
Frameworks
web: Flask, Django, Requests, FastAPI …
testing: pytest, unittest, mock, doctest, tox, hypothesis, nose (2% might be the Python 2 people)
Data science
77% use pandas, 72% NumPy
OS: Windows still at 55%
Packaging:
venv up to 55%
I imaging uv will be on the list next year
requirements.txt 63%, pyproject.toml 32%
virtual env in containers? 47% say no
Michael #3: Anaconda Code add-in for Microsoft Excel
Run their Python-powered projects in Excel locally with the Anaconda Code add-in
Powered by PyScript, an Anaconda supported open source project that runs Python locally without install and setup
Features
Cells Run Independently
Range to Multiple Types
init.py file is static and cannot be edited, with Anaconda Code, users have the ability to access and edit imports and definitions, allowing you to write top-level functions and classes and reuse them wherever you need.
A Customizable Environment
Brian #4: Disabling Scheduled Dependency Updates
David Lord
Interesting discussion of as they happen or batching of upsates to dependencies
dependencies come in
requirements files
GH Actions in CI workflows
pre-commit hooks
David was seeing 60 PRs per month when set up on monthly updates (3 ecosystems * 20 projects)
new tool for updating GH actions: gha-update, allows for local updating of GH dependencies
New process
Run pip-compile, gha-update, and pre-commit locally.
Update a project’s dependencies when actively working on the project, not just whenever a dependency updates.
Note that this works fine for dev dependencies, less so for security updates from run time dependencies. But for libraries, runtime dependencies are usually not pinned.
Extras
Brian:
Test & Code coming back this week
Michael:
Code in a Castle event
Python Bytes badge spotting
Guido’s post removed for moderation
Joke: C will watch in silence
9/3/2024 • 42 minutes, 37 seconds
#398 Open source makes you rich? (and other myths)
Topics covered in this episode:
Open Source Myths
uv 0.3.0 and all the excitement
Top pytest Plugins
A comparison of hosts / providers for Python serverless functions (aka Faas)
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
pytest courses and community at PythonTest.com
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: Open Source Myths
Josh Bressers
Mastodon post kicking off a list of open source myths
Feedback and additional myths compiled to a doc
Some favorites
All open source developers live in Nebraska
It’s all run by hippies
Everything is being rewritten in rust
Features are planned
If the source code is available, it’s open source
A project with no commits for 12 months is abandoned
Many eyes make all bugs shallow
Open source has worse UX
Open source has better UX
Open source makes you rich
Michael #2: uv 0.3.0 and all the excitement
Thanks to Skyler Kasko and John Hagen for the emails.
Additional write up by Simon Willison
Additional write up by Armin Ronacher
End-to-end project management: uv run, uv lock, and uv sync
Tool management: uv tool install and uv tool run (aliased to uvx)
Python installation: uv python install
Script execution: uv can now manage hermetic, single-file Python scripts with inline dependency metadata based on PEP 723.
Brian #3: Top pytest Plugins
Inspired by (and assisted by) Hugo’s Top PyPI Packages
Write up for Finding the top pytest plugins
BTW, pytest-check has made it to 25.
Same day, Jeff Triplett throws my code into Claude 3.5 Sonnet and refactors it
Thanks Jeff Triplett & Hugo for answering how to add Summary and other info
Michael #4: A comparison of hosts / providers for Python serverless functions (aka Faas)
Nice feature matrix of all the options, frameworks, costs, and more
The WASM ones look particularly interesting to me.
Extras
Brian:
When is the next live episode of Python Bytes? - via arewemeetingyet.com
Thanks to Hugo van Kemenade
Some more cool projects by Hugo
Python Logos
PyPI Downloads by Python version for various Python tools, in pretty colors
Python Core Developers over time
Michael:
Code in a Castle Course event - just a couple of weeks left
Ladybird: A truly independent browser
“I'm also interested in your video recording setup, would be nice to have that in the extras too :D”
OBS Studio
Elgato Streamdeck
Elgato Key light
DaVinci Resolve
Joke: DevOps Support Group
via Blaise
Hi, my name is Bob
Group: Hi Bob
I's been 42 days since I last ssh'd into production.
Group: Applause
But only 4 days since I accidentally took down the website
Someone in back: Oh Bob…
8/26/2024 • 42 minutes, 4 seconds
#397 So many PyCon videos
Topics covered in this episode:
pyawaitable
Annotated area charts with plotnine
DeltaDB
PyCon US 2024 Recap + Videos are up
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: pyawaitable
CPython API for asynchronous functions.
by Peter Bierma
It was originally designed to be directly part of CPython - you can read the scrapped PEP about it.
Since this library only uses the public ABI, it's better fit outside of CPython, as a library.
Brian #2: Annotated area charts with plotnine
Nicola Rennie
This is a marvelous, very professional looking plot, and a tutorial for how to achieve it.
Uses plotline, which is “.. an implementation of a grammar of graphics in Python based on ggplot2”
I actually didn’t know the gg in ggplot came from “grammar of graphics”. TIL
Michael #3: DeltaDB
A lightweight, comprehensive solution for managing delta tables built on polars and deltalake.
Deltalake: Delta Lake is an open-source storage format that runs on top of existing data lakes.
Polars: Dataframes powered by a multithreaded, vectorized query engine, written in Rust (aka fluent, rust-based pandas)
See the docs.
Brian #4: PyCon US 2024 Recap + Videos are up
95 countries attended
total attendance of 2,991
2,551 in person
440 remote
Videos available PyConUS
I recommend Playlist → 2024 → view full playlist, as it’s easier to see the talk titles.
I’ve got Paul Gannsle’s pytest for unittesters and Amitosh Swain’s Testing Data Pipelines queued up
Extras
Brian:
Hello, pytest! course available as of last Friday.
Now the fastest way to get started using pytest.
16 lessons (really 12 + intro, outro, code download, pytest flag cheat sheet)
The whole shebang is about 90 min. (faster if you bump up the video speed. :)
Michael:
Cutting back on digital distractions, trying Dumb Phone for iPhone.
See screenshot
Code in a Castle Event
Joke: The Tao of Programming: 4.3
A master was explaining the nature of Tao of to one of his novices, "The Tao is embodied in all software -- regardless of how insignificant," said the master.
"Is the Tao in a hand-held calculator?" asked the novice.
"It is," came the reply.
"Is the Tao in a video game?" continued the novice.
"It is even in a video game," said the master.
"And is the Tao in the DOS for a personal computer?"
The master coughed and shifted his position slightly. "The lesson is over for today," he said.
8/20/2024 • 22 minutes, 21 seconds
#396 uv-ing your way to Python
Topics covered in this episode:
uv venv --python & uv python
Python 3.12.5 released
Compile and use dependencies for multiple Python versions in Tox
Catalog of Dark Patterns
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: uv venv --python & uv python
I was reading this article Python Packaging is Great Now: uv is all you need
It’s a little too “look, a silver bullet” for me, but it did point out some cool uv stuff I didn’t know about.
uv venv venv --python 3.12 creates a virtual environment with Python 3.12,
even if you didn’t have 3.12 installed on your system already.
If it doesn’t work, try adding --python-preference managed
uv python list shows all the python versions on your computer
There’s quite a few “experimental features”
run Run a command or script (experimental)
init Create a new project (experimental)
add Add dependencies to the project (experimental)
remove Remove dependencies from the project (experimental)
sync Update the project's environment (experimental)
lock Update the project's lockfile (experimental)
tree Display the project's dependency tree (experimental)
tool Run and manage tools provided by Python packages (experimental)
python Manage Python versions and installations (experimental)
uv add --dev pytest will add pytest to your dev dependencies.
uv tree rocks
uv might not have “solved packaging” (or maybe it might have)
but it sure is fun to watch the experimentation of different workflows.
Michael #2: Python 3.12.5 released
Lots of changes, see the release notes
Brian #3: Compile and use dependencies for multiple Python versions in Tox
Viktor Rimark
Cool idea to use the {envname}, which specifies the tox environment, in the name of a requirements-dev.txt file name.
Then add a requirements tox target to generate pip-compile-ed files.
Now I gotta try doing all of this with uv lock
Then we need everyone to mod their tools to comply with PEP 571, when/if it’s adopted (covered it last week)
Michael #4: Catalog of Dark Patterns
Including
Bait and Switch
Confirm Shaming
Disguised Ads
Roach Motel
Fake Scarcity
…
Extras
Brian:
Recording of Hello, pytest! is done. Editing now. On track for the 19th (or before).
Michael:
Django 5.1 released
Python 3.13.0 release candidate 1 released
Joke:
clownstrike
ARS Technica article on DMCA for ClownStrike
8/13/2024 • 32 minutes, 19 seconds
#395 pythont compatible packages
Topics covered in this episode:
py-free-threading.github.io
Python’s Supportive and Welcoming Environment is Tightly Coupled to Its Progress
Status pages for sites!
PEP 751 – A file format to list Python dependencies for installation reproducibility
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: py-free-threading.github.io
Track the status of compatibility for free-threaded Python
See the Compatibility status tracking page for what you can use
Lots of resources for getting your package tested and available for pythont
Brian #2: Python’s Supportive and Welcoming Environment is Tightly Coupled to Its Progress
“Python is as popular as it is today because we have gone above and beyond to make this a welcoming community. Being a friendly and supportive community is part of how we are perceived by the wider world and is integral to the wide popularity of Python. We won a “Wonderfully Welcoming Award” last year at GitHub Universe. Over and over again, the tech press refers to Python as a supportive community.”
Some communication recently, with the recent bylaws change, didn’t live up to our promise to be welcoming
Please read the article for more details.
Another quote: “We have a moral imperative – as one of the very best places to bring new people into tech and into open source – to keep being good at welcoming new people. If we do not rise and continue to rise every day to this task, then we are not fulfilling our own mission, “to support and facilitate the growth of a diverse and international community of Python programmers.” Technical skills are a game-changer for the people who acquire them and joining a vast global network of people with similar interests opens many doors. Behavior that contributes to a hostile environment around Python or throws up barriers and obstacles to those who would join the Python community must be addressed because it endangers what we have built here.”
Michael #3: Status pages for sites!
Based on Uptime Kuma I covered last week
Python Bytes status
Talk Python status
Brian #4: PEP 751 – A file format to list Python dependencies for installation reproducibility
Brett Cannon
Motivation
Currently, no standard exists to:
Specify what top-level dependencies should be installed into a Python environment.
Create an immutable record, such as a lock file, of which dependencies were installed.
Considering there are at least five well-known solutions to this problem in the community (pip freeze, pip-tools, uv, Poetry, and PDM), there seems to be an appetite for lock files in general.
Rationale
The format is designed so that a locker which produces the lock file and an installer which consumes the lock file can be separate tools. …
The file format is designed to be human-readable. …Finally, the format is designed so that viewing a diff of the file is easy by centralizing relevant details.
The file format is also designed to not require a resolver at install time. …
Extras
Brian:
Hello, pytest! course is going well, and is purchasable as in pre-release mode.
Planning on Aug 19 (or before) deadline.
Not sure what the final price will be, but I’m starting with $10.
I want people to want to watch it even just so see if they want to recommend to co-workers so the people around them can ramp up on pytest quickly.
Michael:
Mypy 1.11 Released
FastHTML (more next week)
Coming up on the final chance to be part of the Code in a Castle event.
Joke: Open source OpenAI?
8/6/2024 • 29 minutes, 24 seconds
#394 Python is easy now?
Topics covered in this episode:
Python is easy now
Trying out free-threaded Python on macOS
Module itertools overview
uptime-kuma
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: Python is easy now
or Postmodern Python
or Beyond Hypermodern
Chris Ardene
Mostly a cool review of using rye for
setup
linting
typing
testing
documentation
CI/CD
Also a nice discussion of how to deal with a Monorepo for Python projects
Michael #2: Trying out free-threaded Python on macOS
via pycoders
How to install free threaded Python the easy way
Testing the CPU bound work speed ups for FT Python
Brian #3: Module itertools overview
Rodrigo
20 tools that every Python developer should be aware of.
In 5 categories
Reshaping
Filtering
Combinatorial
Infinite
Iterators that complement other tools
Things I forgot about
chain
pairwise
zip_longest
tee
Michael #4: uptime-kuma
A fancy self-hosted monitoring tool
Features
Monitoring uptime for HTTP(s) / TCP / HTTP(s) Keyword / HTTP(s) Json Query / Ping / DNS Record / Push / Steam Game Server / Docker Containers
Fancy, Reactive, Fast UI/UX
Notifications via Telegram, Discord, Gotify, Slack, Pushover, Email (SMTP), and 90+ notification services, click here for the full list
20-second intervals
Multi Languages
Multiple status pages
Map status pages to specific domains
Ping chart
Certificate info
Proxy support
2FA support
Extras
Brian:
Still working on a new pytest course. Hoping to get it released soon-ish.
Michael:
Open source Switzerland
spyoungtech/FreeSimpleGUI — actively maintained fork of the last release of PySimpleGUI
Joke: Java vs. JavaScript
7/30/2024 • 28 minutes, 37 seconds
#393 Dare enter the Bash dungeon?
Topics covered in this episode:
Marimo: “Future of Notebooks”
pytest 8.3.0 & 8.3.1 are out
Python Language Summit 2024
bash-dungeon
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: Marimo: “Future of Notebooks”
via Matt Wilkie
An open-source reactive notebook for Python
Run one cell and marimo reacts by automatically running affected cells, eliminating the error-prone chore of managing notebook state.
Marimo's reactive UI elements, like dataframe GUIs and plots, make working with data feel refreshingly fast, futuristic, and intuitive.
Rapidly experiment with code and models
Bind UI elements to Python values
Pick-up-and-play design, with depth for power users
See the FAQ
Brian #2: pytest 8.3.0 & 8.3.1 are out
Real excited to get --xfail-tb flag added
This detaches xfail tracebacks from -rx/-ra (which was how it was pre-8.0)
Keyword matching for marker expressions, that’s fun.
pytest -v -m "device(serial='123')"
--no-fold-skipped allows for explit reporting of names of skipped tests
Plus many more improvements, bug fixes, and doc improvements
Michael #3: Python Language Summit 2024
Should Python adopt Calendar Versioning?: talk by Hugo van Kemenade
Python's security model after the xz-utils backdoor: talk by Pablo Galindo Salgado
Native Interface and Limited C API: talks by Petr Viktorin and Victor Stinner
Free-threading ecosystems: talk by Daniele Parmeggiani
Python on Mobile: talk by Malcolm Smith
PyREPL -- New default REPL written in Python: talk by Pablo Galindo Salgado, Łukasz Langa, and Lysandros Nikolaou
Should we make pdb better?: talk by Tian Gao
Limiting yield in async generators: talk by Zac Hatfield-Dodds
Annotations as Transforms: talk by Jason R. Coombs
Lightning Talks, featuring talks by Petr Viktorin, David Hewitt, Emily Morehouse, Łukasz Langa, Pablo Galindo Salgado, and Yury Selivanov
Brian #4: bash-dungeon
“This game is intended to teach new users how to use their shell in a fun and interactive way.”
Just clone the repo and start exploring with cd, ls, and cat.
First moves
cd bash-dungeon
ls
cd Enter
ls
cat parchment
A fun way to learn some commands you might need and/or might have forgotten about.
Extras
Brian:
Python 3.12.0b4, final beta, is out
If hanging out on discuss.python.org, please checkout
Community Guidelines
And if it’s still not clear why we need these, check out
Inclusive communications expectations in Python spaces
Google Chrome news
Michael:
PySimpleGUI goes commercial with obfuscated “source open”?
Still have seats for Code in a Castle event
Reactive Dashboards with Shiny for Python free course
Joke:
40 Million in in Series A Funding - may be a lot of reading, but I found it funny
Thanks to VM Brasseur for sharing this one.
Also a few from pyjokes 0.7.2 (first new version since 2019)
If at first you don't succeed, call it version 1.0.
A product manager walks into a bar, asks for drink. Bartender says no, but will consider adding later.
Triumphantly, Beth removed Python 2.7 from her server in 2030. 'Finally!' she said with glee, only to see the announcement for Python 4.4.1
Although, if CalVer, PEP 2026, happens, that’ll just be Python 3.30.0.
7/23/2024 • 31 minutes, 55 seconds
#392 The votes have been counted
Topics covered in this episode:
2024 PSF Board Election & Proposed Bylaw Change Results
SATYRN: A modern Jupyter client for Mac
Incident Report: Leaked GitHub Personal Access Token
Extra extra extra
Extras
Joke
Watch on YouTube
About the show
Sponsored by Code Comments, an original podcast from RedHat: pythonbytes.fm/code-comments
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: 2024 PSF Board Election & Proposed Bylaw Change Results
New board members
Tania Allard
KwonHan Bae
Cristián Maureira-Fredes
Congrats to new board members
If you want to consider becoming a board member, there are 4 seats up for vote next year.
All 3 bylaw changes passed, by a wide margin.
Details of changes
Change 1: Merging Contributing and Managing member classes
Change 2: Simplifying the voter affirmation process by treating past voting activity as intent to continue voting
Change 3: Allow for removal of Fellows by a Board vote in response to Code of Conduct violations, removing the need for a vote of the membership
Michael #2: SATYRN: A modern Jupyter client for Mac
A Jupyter client app for macOS
Comes with a command palette
LLM assistance (local or cloud?)
Built in Black formatter
Currently in alpha
Business model unknown
Brian #3: Incident Report: Leaked GitHub Personal Access Token
Suggested by Galen Swint
See also JFrog blog: Binary secret scanning helped us prevent (what might have been) the worst supply chain attack you can imagine
A GitHub access token found it’s way into a .pyc file, then into a docker image.
JFrog found it through some regular scans.
JFrog notified PYPI security.
Token was destroyed within 17 minutes. (nice turnaround)
Followup scan revealed that no harm was done.
Takaways (from Ee Durbin):
Set aggressive expiration dates for API tokens (If you need them at all)
Treat .pyc files as if they were source code
Perform builds on automated systems from clean source only.
Michael #4: Extra extra extra
Python 3.13.0 beta 3 released
Ice got a lot better
I Will Piledrive You If You Say AI Again | Prime Reacts Video
Follow up actions for polyfill supply chain attack
Developer Ecosystem Survey 2024
Code in a Castle still has seats open
Extras
Brian:
A new pytest course in the works
Quick course focusing on
core pytest features + some strategy and Design for Testability concepts
Idea
everyone on the team (including managers) can take the new course.
1-2 people on a team take “The Complete pytest Course” to become the teams local pytest experts.
Python People is on an indefinite hold
Python Test → back to Test & Code (probably)
I’m planning a series (maybe a season) on TDD which will be language agnostic.
Plus I still have tons of Test & Code stickers and no Python Test stickers.
New episodes planned for August
Joke: I need my intellisense (autocomplete)
7/17/2024 • 25 minutes, 44 seconds
#391 A weak episode
Topics covered in this episode:
Vendorize packages from PyPI
A Guide to Python's Weak References Using weakref Module
Making Time Speak
How Should You Test Your Machine Learning Project? A Beginner’s Guide
Extras
Joke
Watch on YouTube
About the show
Sponsored by Code Comments, an original podcast from RedHat: pythonbytes.fm/code-comments
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: Vendorize packages from PyPI
Allows pure-Python dependencies to be vendorized: that is, the Python source of the dependency is copied into your own package.
Best used for small, pure-Python dependencies
Brian #2: A Guide to Python's Weak References Using weakref Module
Martin Heinz
Very cool discussion of weakref
Quick garbage collection intro, and how references and weak references are used.
Using weak references to build data structures.
Example of two kinds of trees
Implementing the Observer pattern
How logging and OrderedDict use weak references
Michael #3: Making Time Speak
by Prayson, a former guest and friend of the show
Translating time into human-friendly spoken expressions
Example: clock("11:15") # 'quarter past eleven'
Features
Convert time into spoken expressions in various languages.
Easy-to-use API with a simple and intuitive design.
Pure Python implementation with no external dependencies.
Extensible architecture for adding support for additional languages using the plugin design pattern.
Brian #4: How Should You Test Your Machine Learning Project? A Beginner’s Guide
François Porcher
Using pytest and pytest-cov for testing machine learning projects
Lots of pieces can and should be tested just as normal functions.
Example of testing a clean_text(text: str) -> str function
Test larger chunks with canned input and expected output.
Example test_tokenize_text()
Using fixtures for larger reusable components in testing
Example fixture: bert_tokenizer() with pretrained data
Checking coverage
Extras
Michael:
Twilio Authy Hack
Google Authenticator is the only option? Really?
Bitwarden to the rescue
Requires (?) an update to their app, whose release notes (v26.1.0) only say “Bug fixes”
Introducing Docs in Proton Drive
This is what I called on Mozilla to do in “Unsolicited Advice for Mozilla and Firefox” But Proton got there first
Early bird ending for Code in a Castle course
Joke: I Lied
7/9/2024 • 26 minutes, 16 seconds
#390 Coding in a Castle
Topics covered in this episode:
Joining Strings in Python: A "Huh" Moment
10 hard-to-swallow truths they won't tell you about software engineer job
My thoughts on Python in Excel
Extra, extra, extra
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: Joining Strings in Python: A "Huh" Moment
Veronica Berglyd Olsen
Standard solution to “read lines from a file, do some filtering, create a multiline string”:
f = open("input_file.txt")
filtered_text = "\n".join(x for x in f if not x.startswith("#"))
This uses a generator, file reading, and passes the generator to join.
Another approach is to add brackets and pass that generator to a list comprehension:
f = open("input_file.txt")
filtered_text = "\n".join([x for x in f if not x.startswith("#")])
At first glance, this seems to just be extra typing, but it’s actually faster by 16% on CPython due to the implementation of .join() doing 2 passes on input if passed a generator.
From Trey Hunner: “I do know that it’s not possible to do 2 passes over a generator (since it’d be exhausted after the first pass) so from my understanding, the generator version requires an extra step of storing all the items in a list first.”
Michael #2: 10 hard-to-swallow truths they won't tell you about software engineer job
College will not prepare you for the job
You will rarely get greenfield projects
Nobody gives a BLANK about your clean code
You will sometimes work with incompetent people
Get used to being in meetings for hours
They will ask you for estimates a lot of times
Bugs will be your arch-enemy for life
Uncertainty will be your toxic friend
It will be almost impossible to disconnect from your job
You will profit more from good soft skills than from good technical skills
Brian #3: My thoughts on Python in Excel
Felix Zumstein
Interesting take on one person’s experience with trying Python in Excel.
“We wanted an alternative to VBA, but got an alternative to the Excel formula language”
“Python runs in the cloud on Azure Container Instances and not inside Excel.”
“DataFrames are great, but so are NumPy arrays and lists.”
… lots of other interesting takaways.
Michael #4: Extra, extra, extra
Code in a castle - Michael’s Python Zero to Hero course in Tuscany
Polyfill.io JavaScript supply chain attack impacts over 100K sites
Now required reading: Reasons to avoid Javascript CDNs
Mac users served info-stealer malware through Google ads
HTMX for the win!
ssh to run remote commands
> ssh user@server "command_to_run --arg1 --arg2"
Extras
Brian:
A fun reaction to AI - I will not be showing the link on our live stream, due to colorful language.
Michael:
Coding in a Castle Developer Education Event
Polyfill.io JavaScript supply chain attack impacts over 100K sites
See Reasons to avoid Javascript CDNs
Joke: HTML Hacker
7/2/2024 • 36 minutes, 39 seconds
#389 More OOP for Python?
Topics covered in this episode:
Solara UI Framework
Coverage at a crossroads
“Virtual” methods in Python classes
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: Solara UI Framework
via Florian
A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
Solara lets you build web apps from pure Python using ipywidgets or a React-like API on top of ipywidgets.
These apps work both inside the Jupyter Notebook and as standalone web apps with frameworks like FastAPI.
See the Examples page.
Based on Reacton
By building on top of ipywidgets, Solara automatically leverage an existing ecosystem of widgets and run on many platforms, including JupyterLab, Jupyter Notebook, Voilà, Google Colab, DataBricks, JetBrains Datalore, and more.
Brian #2: Coverage at a crossroads
Ned Batchelder is working on making coverage.py faster.
Includes a nice, quick explanation of roughly how coverage.py works
with trace function and arcs used for branch coverage.
And how trace slows things down for lines we know are already covered.
There are cool ideas from SlipCover that could be applicable.
There’s also sys.monitoring from Python 3.12 that helps with line coverage, since you can disable it for lines you already have info on.
It doesn’t quite complete the picture for branch coverage, though.
Summary:
jump in and help if you can
read it anyway for a great mental model of how coverage.py works.
Michael #3: “Virtual” methods in Python classes
via Brian Skinn
PEP 698 just got accepted, defining an @override decorator for type hinting, to help avoid errors in subclasses that override methods.
Only affects type checkers but allows you to declare a “link” between the base method and derived class method with the intent of overriding it using OOP. If there is a mismatch, it’s an error.
Python 3.12’s documentation
Makes Python a bit more like C# and other more formal languages
Brian #4: Parsing Python ASTs 20x Faster with Rust
Evan Doyle
Tach is “a CLI tool that lets you define and enforce import boundaries between Python modules in your project.”
we covered it in episode 384
When used to analyze Sentry’s ~3k Python file codebase, it took about 10 seconds.
Profiling analysis using py-spy and speedscope pointed to a function that spends about 2/3 of the time parsing the AST, and about 1/3 traversing it.
That portion was then rewritten in Rust, resulting in 10x speedup, ending in about 1 second.
This is a cool example of not just throwing Rust at a speed problem right away, but doing the profiling homework first, and focusing the Rust rewrite on the bottleneck.
Extras
Brian:
I brought up pkgutil.resolve_name() last week on episode 388
Brett Cannon says don’t use that, it’s deprecated
Thanks astroboy for letting me know
Will we get CalVer for Python?
it was talked about at the language summit
There’s also pep 2026, in draft, with a nice nod in the number of when it might happen.
3.13 already in the works for 2024
3.14 slated for 2025, and we gotta have a pi release
So the earliest is then 2026, with maybe a 3.26 version ?
Saying thanks to open source maintainers
Great write-up by Brett Cannon about how to show your appreciation for OSS maintainers.
Be nice
Be an advocate
Produce your own open source
Say thanks
Fiscal support
On topic
Thanks Brett for pyproject.toml. I love it.
Michael:
The Shiny for Python course is out! Plus, it’s free so come and get it.
Joke: Tao of Programming: Book 1: Into the Silent Void, Part 1
6/24/2024 • 31 minutes, 12 seconds
#388 Don't delete all the repos
Topics covered in this episode:
PSF Elections coming up
Cloud engineer gets 2 years for wiping ex-employer’s code repos
Python: Import by string with pkgutil.resolve_name()
DuckDB goes 1.0
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: PSF Elections coming up
This is elections for the PSF Board and for 3 bylaw changes.
To vote in the PSF election, you need to be a Supporting, Managing, Contributing, or Fellow member of the PSF, …
And affirm your voting status by June 25.
See Affirm your PSF Membership Voting Status for more details.
Timeline
Board Nominations open: Tuesday, June 11th, 2:00 pm UTC
Board Nominations close: Tuesday, June 25th, 2:00 pm UTC
Voter application cut-off date: Tuesday, June 25th, 2:00 pm UTC
same date is also for voter affirmation.
Announce candidates: Thursday, June 27th
Voting start date: Tuesday, July 2nd, 2:00 pm UTC
Voting end date: Tuesday, July 16th, 2:00 pm UTC
See also Thinking about running for the Python Software Foundation Board of Directors? Let’s talk!
There’s still one upcoming office hours session on June 18th, 12 PM UTC
And For your consideration: Proposed bylaws changes to improve our membership experience
3 proposed bylaws changes
Michael #2: Cloud engineer gets 2 years for wiping ex-employer’s code repos
Miklos Daniel Brody, a cloud engineer, was sentenced to two years in prison and a restitution of $529,000 for wiping the code repositories of his former employer in retaliation for being fired.
The court documents state that Brody's employment was terminated after he violated company policies by connecting a USB drive.
Brian #3: Python: Import by string with pkgutil.resolve_name()
Adam Johnson
You can use pkgutil.resolve_name("[HTML_REMOVED]:[HTML_REMOVED]")to import classes, functions or modules using strings.
You can also use importlib.import_module("[HTML_REMOVED]")
Both of these techniques are so that you have an object imported, but the end thing isn’t imported into the local namespace.
Michael #4: DuckDB goes 1.0
via Alex Monahan
The cloud hosted product @MotherDuck also opened up General Availability
Codenamed "Snow Duck"
The core theme of the 1.0.0 release is stability.
Extras
Brian:
Sending us topics. Please send before Tuesday. But any time is welcome.
NumPy 2.0
htmx 2.0.0
Michael:
Get 6 months of PyCharm Pro for free. Just take a course (even a free one) at Talk Python Training. Then visit your account page > details tab and have fun.
Coming soon at Talk Python: Shiny for Python
Joke: .gitignore thoughts won't let me sleep
6/18/2024 • 21 minutes, 59 seconds
#387 Heralding in a new era of database queries
Topics covered in this episode:
Dataherald
Python's many command-line utilities
Distroless Python
functools.cache, cachetools, and cachebox
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: Dataherald
Interact with your SQL database, Natural Language to SQL using LLMs.
Allows you to set up an API from your database that can answer questions in plain English
Uses include
Allow business users to get insights from the data warehouse without going through a data analyst
Enable Q+A from your production DBs inside your SaaS application
Create a ChatGPT plug-in from your proprietary data
Brian #2: Python's many command-line utilities
Trey Hunner
Too many to list, but here’s some fun ones
json.tool - nicely format json data
calendar - print the calendar
current by default, but you can pass in year and month
gzip, ftplib, tarfile, and other unixy things
handy on Windows
cProfile & pstats
Michael #3: Distroless Python
via Patrick Smyth
What is distroless anyway?
These are container images without package managers or shells included.
Debugging these images presents some wrinkles (can't just exec into a shell inside the image), but they're a lot more secure.
Chainguard, creates low/no CVE distroless images based on our FOSS distroless OS, Wolfi.
Some Python use-cases:
docker run -it cgr.dev/chainguard/python:latest
# The entrypoint is a Python REPL, since no b/a/sh is included
docker run -it cgr.dev/chainguard/python:latest-dev
# This is their dev version and has pip, bash, apk, etc.
Brian #4: functools.cache, cachetools, and cachebox
functools cache and lru_cache - built in
cachetools - “This module provides various memoizing collections and decorators, including variants of the Python Standard Library's @lru_cache function decorator.”
cachebox - “The fastest caching Python library written in Rust”
Extras
Brian:
Python 3.12.4 is out
VSCode has some pytest improvements
Michael:
Time for a bartender alternative, I’ve switched to Ice.
Rocket.chat as an alternative to Slack
Joke: CSS Cartoons
6/11/2024 • 27 minutes, 52 seconds
#386 Major releases abound
Topics covered in this episode:
NumPy 2.0 release date is June 16
Uvicorn adds multiprocess workers
pixi
JupyterLab 4.2 and Notebook 7.2 are available
Extras
Joke
Watch on YouTube
About the show
Sponsored by Mailtrap: pythonbytes.fm/mailtrap
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: NumPy 2.0 release date is June 16
“This release has been over a year in the making, and is the first major release since 2006. Importantly, in addition to many new features and performance improvement, it contains breaking changes to the ABI as well as the Python and C APIs. It is likely that downstream packages and end user code needs to be adapted - if you can, please verify whether your code works with NumPy 2.0.0rc2.”
NumPy 2.0.0 Release Notes
NumPy 2.0 migration guide
including “try just running ruff check path/to/code/ --select NPY201”
“Many of the changes covered in the 2.0 release notes and in this migration guide can be automatically adapted in downstream code with a dedicated Ruff rule, namely rule NPY201.”
Michael #2: Uvicorn adds multiprocess workers
via John Hagen
The goal was to no longer need to suggest that people use Gunicorn on top of uvicorn. Uvicorn can now in a sense "do it all”
Steps to use it and background on how it works.
Brian #3: pixi
Suggested by Vic Kelson
“pixi is a cross-platform, multi-language package manager and workflow tool built on the foundation of the conda ecosystem.”
Tutorial: Doing Python development with Pixi
Some quotes from Vic:
“Pixi is a project manager, written in Rust, that allows you to build Python projects without having Python previously installed. It’s installable with Homebrew (brew install pixi on Linux and MacOS). There’s support in VSCode and PyCharm via plugins. By default, pixi fetches packages from conda-forge, so you get the scientific stack in a pretty reliable and performant build. If a package isn’t on conda-forge, it’ll look on PyPI, or I believe you can force it to look on PyPI if you like.”
“So far, it works GREAT for me. What really impressed me is that I got a Jupyter environment with CuPy utilizing my aging Nvidia GPU on the FIRST TRY.”
Michael #4: JupyterLab 4.2 and Notebook 7.2 are available
JupyterLab 4.2.0 has been released! This new minor release of JupyterLab includes 3 new features, 20 enhancements, 33 bug fixes and 29 maintenance tasks.
Jupyter Notebook 7.2.0 has also been released
Highlights include
Easier Workspaces Management with GUI
Recently opened/closed files
Full notebook windowing mode by default (renders only the cells visible in the window, leading to improved performance)
Improved Shortcuts Editor
Dark High Contrast Theme
Extras
Brian:
Help test Python 3.13!
Help us test free-threaded Python without the GIL
both from Hugo van Kemenade
Python Test 221: How to get pytest to import your code under test is out
Michael:
Bend follow up from Bernát Gábor
“Bend looks roughly like Python but is nowhere there actually. For example it has no for loops, instead you're meant to use bend keyword (hence the language name) to expand calculations and another keyword to join branches. So basically think of something that resembles Python at high level, but without being compatible with that and without any of the standard library or packages the Python language provides. That being said does an impressive job at parallelization, but essentially it's a brand new language with new syntax and paradigms that you will have to learn, it just shares at first look similarities with Python the most.”
Joke: Do-while
6/4/2024 • 21 minutes
#385 RESTing on Postgres
Topics covered in this episode:
PostgresREST
How Python Asyncio Works: Recreating it from Scratch
Bend
The Smartest Way to Learn Python Regular Expressions
Extras
Joke
Watch on YouTube
About the show
Sponsored by Mailtrap: pythonbytes.fm/mailtrap
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: PostgresREST
PostgREST serves a fully RESTful API from any existing PostgreSQL database. It provides a cleaner, more standards-compliant, faster API than you are likely to write from scratch.
Speedy
First the server is written in Haskell using the Warp HTTP server (aka a compiled language with lightweight threads).
Next it delegates as much calculation as possible to the database.
Finally it uses the database efficiently with the Hasql library
PostgREST handles authentication (via JSON Web Tokens) and delegates authorization to the role information defined in the database. This ensures there is a single declarative source of truth for security.
Brian #2: How Python Asyncio Works: Recreating it from Scratch
Jacob Padilla
Cool tutorial walking through how async works, including
Generators Review
The Event Loop
Sleeping
Yield to Await
Await with AsyncIO
Another great async resource is:
Build your Own Async
David Beasley talk from 2019
Michael #3: Bend
A massively parallel, high-level programming language.
With Bend you can write parallel code for multi-core CPUs/GPUs without being a C/CUDA expert with 10 years of experience.
It feels just like Python!
No need to deal with the complexity of concurrent programming: locks, mutexes, atomics... any work that can be done in parallel will be done in parallel.
Brian #4: The Smartest Way to Learn Python Regular Expressions
Christian Mayer, Zohaib Riaz, and Lukas Rieger
Self published ebook on Python Regex that utilizes
book form readings, links to video course sections
puzzle challenges to complete online
It’s a paid resource, but the min is free.
Extras
Brian:
Replay - A graphic memoir by Prince of Persia creator Jordan Mechner, recounting his own family story of war, exile and new beginnings.
Michael:
PyCon 2026
Joke: Shells Scripts
5/27/2024 • 24 minutes, 4 seconds
#384 Force push lightly
Topics covered in this episode:
Git: Force push safely with --force-with-lease and --force-if-includes
Thoughts from PyCon 2024
Being friendly: Strategies for friendly fork management
tach
Extras
Joke
Watch on YouTube
About the show
Sponsored by Mailtrap: pythonbytes.fm/mailtrap
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: Git: Force push safely with --force-with-lease and --force-if-includes
Adam Johnson
Using gentle force
Avoid stomping on remote changes with a couple extra flags.
Michael #2: Thoughts from PyCon 2024
PyCon is special - the connections you make are always more than you expect
Great to see many old friends
Did a ”live” Talk Python episode that’ll be out in a few weeks.
The talks look great, we’ll let you know when they land on YouTube.
Masks were a mistake - universally heard complaints from fellow attendees. This is my two cents towards a more reasonable next PyCon.
Brian #3: Being friendly: Strategies for friendly fork management
That’s part 2.
Part 1 is Being friendly: Friendly forks 101
Lessley Dennington on GitHub Blog
Examples of long running friendly forks
git-for-windows/git, microsift/git, github/git
two public, one private
Fork management strategies - when pulling changes downstream
merging rebase
git-for-windows/git uses this proactively and regularly
fake merge + rebase
new branch
microsoft/git uses this
new branch from upstream major versions
merge previous changes to new branch
traditional merge
github/git uses this, conservatively, after a few point bug fix versions
Michael #4: tach
A Python tool to enforce a modular, decoupled package architecture.
tach allows you to define boundaries and control dependencies between your Python packages.
Each package can define its public interface.
If a package tries to import from another package that is not listed as a dependency, tach will report an error.
If a package tries to import from another package and does not use its public interface, with strict: true set, tach will report an error.
Zero runtime impact.
Extras
Brian:
Logfire - new observability platform from the pydantic team - free for now
Michael:
10% off the new spaCy course throughout May
Joke: Evolution of smart products
5/21/2024 • 25 minutes, 50 seconds
#383 Why aren’t devs shipping faster?
Topics covered in this episode:
I asked 100 devs why they aren’t shipping faster. Here’s what I learned
Python 3.13.0 beta 1 released
A theme editor for JupyterLab
rich-argparse
Extras
Joke
Watch on YouTube
About the show
Sponsored by Mailtrap: pythonbytes.fm/mailtrap
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: I asked 100 devs why they aren’t shipping faster. Here’s what I learned
by Daksh Gupta (via PyCoders)
What’s stopping you from shipping faster?
Dependency bugs
Complicated codebase
>There is so much undocumented in our service, including poor records of new features, nonexistent or outdated info on our dependencies, or even essential things like best practices for testing, a lot of time is wasted in syncs trying to find the right information
QA Loops
Waiting for spec
> At Amazon? Meetings, approval, talking to 10 different stakeholders because changing the color of a button affects 15 micro services
Writing tests
Deployment/build speed
Scope creep
> The human tendency to stuff last-minute items into the crevices of their luggage minutes before leaving for the airport manifests itself at software companies as scope creep.
Unclear requirements
Excessive meetings
Motivation
>honest answer is i was on ads
>and that’s a very old / complicated / large stack (edited)
>and i didn’t understand it
>my friends on younger teams seemed happier, i was miserable
DORA metrics
Brian #2: Python 3.13.0 beta 1 released
"Python 3.13 is still in development. This release, 3.13.0b1, is the first of four beta release previews of 3.13.”
New REPL, featuring multi-line editing, color support, colorized exception tracebacks
Cool GIL, JIT, and GC features
Typing changes, including typing.TypeIs .
See last weeks episode and TypeIs does what I thought TypeGuard would do in Python
Some nice dead battery removals
and more
But seriously, the REPL is cool. Just ask Trey
The new REPL in Python 3.13 - Trey Hunner
Michael #3: A theme editor for JupyterLab
by Florence Haudin
A new tool for authoring JupyterLab themes
To lower the bar for customizing JupyterLab we created a new tool providing a simple interface for tuning the JupyterLab appearance interactively.
See jupyterlab-theme-editor on github
Brian #4: rich-argparse
“Format argparse and optparse help using rich.”
“rich-argparse improves the look and readability of argparse's help while requiring minimal changes to the code.”
They’re not kidding. 2 line code change.
from rich_argparse import RichHelpFormatter
parser = argparse.ArgumentParser(..., formatter_class=RichHelpFormatter)
Extras
Brian:
pytest course is now switched to the new platform.
I sent out an email including how to save their spot on the old site and mark that spot complete on the new site.
There’s now comments on the course now. Trying that out. If you’ve got a question, just ask in that section.
Michael:
A new Talk Python course: Getting Started with NLP and spaCy
Joke: Testing holiday
5/14/2024 • 31 minutes
#382 A Simple Game
Topics covered in this episode:
act: Run your GitHub Actions locally!
portr
Annotating args and kwargs in Python
github badges
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of
the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: act: Run your GitHub Actions locally!
Why?
“Fast Feedback - Rather than having to commit/push every time you want to test out the changes you are making to your .github/workflows/ files (or for any changes to embedded GitHub actions), you can use act to run the actions locally. The environment variables and filesystem are all configured to match what GitHub provides.”
“Local Task Runner - I love make. However, I also hate repeating myself. With act, you can use the GitHub Actions defined in your .github/workflows/ to replace your Makefile!”
Docs: nektosact.com
Uses Docker to run containers for each action.
Michael #2: portr
Open source ngrok alternative designed for teams
Expose local http, tcp or websocket connections to the public internet
Warning: Portr is currently in beta. Expect bugs and anticipate breaking changes.
Server setup (docker basically).
Brian #3: Annotating args and kwargs in Python
Redowan Delowar
I don’t think I’ve ever tried, but this is a fun rabbit hole.
Leveraging bits of PEP-5891, PEP-6462, PEP-6553, and PEP-6924.
Punchline:
from typing import TypedDict, Unpack *# Python 3.12+*
*# from typing_extensions import TypedDict, Unpack # < Python 3.12*
class Kw(TypedDict):
key1: int
key2: bool
def foo(*args: Unpack[tuple[int, str]], **kwargs: Unpack[Kw]) -> None:
...
A recent pic from Redowan’s blog:
TypeIs does what I thought TypeGuard would do in Python
Michael #4: github badges
A curated list of GitHub badges for your next project
Extras
Brian:
Fake job interviews target developers with new Python backdoor
Later this week, course.pythontest.com will shift from Teachable to Podia
Same great content. Just a different backend.
To celebrate, get 25% off at pythontest.podia.com now through this Sunday using coupon code PYTEST
Getting the most out of PyCon, including juggling - Rob Ludwick
Latest PythonTest episode, also cross posted to pythonpeople.fm
3D visualization of dom
Michael:
Djangonauts Space Session 2 Applications Open! More background at Djangonauts, Ready for Blast-Off on Talk Python.
Self-Hosted Open Source - Michael Kennedy on Django Chat
Joke: silly games
Closing song: Permission Granted
5/7/2024 • 28 minutes, 10 seconds
#381 Python Packages in the Oven
Topics covered in this episode:
Announcing py2wasm: A Python to Wasm compiler
Exploring Python packages with Oven and PyPI Browser
PyCharm Local LLM
Google shedding Python devs (at least in the US).
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of
the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: Announcing py2wasm: A Python to Wasm compiler
py2wasm converts your Python programs to WebAssembly, running them at 3x faster speeds
thanks to Nuitka
Brian #2: Exploring Python packages with Oven and PyPI Browser
pypi.org is great, but there are some handy alternatives
Oven
Shows how to install stuff with pip, pdm, rye, and poetry
Similar meta and description as PyPI
Includes README.md view (no tables yet, though)
Nice listing of versions
Ability to look at what files are in wheels and tarballs (very cool)
Can deploy yourself. Node/Remix app.
Really slick.
PyPI Browser
View versions
View wheel and tarball contents.
Metadata and contents.
No README view
Is a Starlette app that you can deploy on your on with a private registry. So that’s cool.
Michael #3: PyCharm Local LLM
Pretty awesome full line completer based on a local LLM for PyCharm
Requires PyCharm Professional
An example, given this partial function in Flask:
@blueprint.get('/listing')
def listing():
videos = video_service.all_videos()
Typing ret →
That is, typing ret autocompletes to:
return flask.render_template('home/listing.html', videos=videos)
Which is pretty miraculous, and correct.
Brian #4: Google shedding Python devs (at least in the US).
Google lays off staff from Flutter, Dart and Python teams weeks before its developer conference - techcrunch
Python, Flutter teams latest on the Google chopping block - The Register
“Despite Alphabet last week reporting a 57 percent year-on-year jump in net profit to $23.66 billion for calendar Q1, more roles are being expunged as the mega-corp cracks down on costs.”
“As for the Python team, the current positions have reportedly been "reduced" in favor of a new team based in Munich.”
MK: Related and timely: How one power-hungry leader destroyed Google search
Extras
Brian:
Python Gotcha: strip, lstrip, rstrip can remove more than expected
Reminder: You probably want .removesuffix() and .removeprefix()
Michael:
Using Llama3 in LMStudio
Joke: Broken System
4/30/2024 • 28 minutes, 55 seconds
#380 Debugging with your eyes
Topics covered in this episode:
NumFOCUS concerns
leaping pytest debugger llm
Extra, Extra, Extra,
PyPI has completed its first security audit
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of
the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: NumFOCUS concerns
Suggested by Pamphile Roy
Write up of the current challenges faced by NumFOCUS, by Paul Ivanov (one of the OG of Scientific Python: Jupyter, Matplotlib, etc.)
Struggling to meet the needs of sponsored and affiliated projects.
In February, NumFOCUS announced it is moving in a new direction.
NumFOCUS initiated an effort to run an election for open board seats and proposed changing its governance structure.
Some projects are considering and actively pursuing alternative venues for fiscal sponsorship.
Quite a bit more detail and discussion in the article.
NumFOCUS covers a lot of projects
NumPy, Matplotlib, pandas, Jupyter, SciPy, Astropy, Bokeh, Dask, Conda, and so many more.
Michael #2: leaping pytest debugger llm
You can ask Leaping questions like:
Why am I not hitting function x?
Why was variable y set to this value?
What was the value of variable x at this point?
What changes can I make to this code to make this test pass?
Brian #3: Extra, Extra, Extra,
2024 Developer Summit
Also suggested by Pamphile, related to Scientific Python
The Second Scientific Python Developer Summit , June 3-5, Seattle, WA
Lots of great work came out of the First Summit in 2023
pytest-regex - Use regexs to specify tests to run
Came out of the ’23 summit
I’m not sure if I’m super happy about this or a little afraid that I probably could use this.
Still, cool that it’s here.
Cool short example of using __init__ and __call__ to hand-roll a decorator.
ruff got faster
Michael #4: PyPI has completed its first security audit
Trail of Bits spent a total of 10 engineer-weeks of effort identifying issues, presenting those findings to the PyPI team, and assisting us as we remediated the findings.
Scope: The audit was focused on "Warehouse", the open-source codebase that powers pypi.org
As a result of the audit, Trail of Bits detailed 29 different advisories discovered across both codebases. When evaluating severity level of each advisory, 14 were categorized as "informational", 6 as "low", 8 as "medium" and zero as "high".
Extras
Brian:
pytest course community to try out Podia Communities.
Anyone have a podia community running strong now?
If so, let me know through Mastodon: @[email protected]
Want to join the community when it’s up and running?
Same. Or join our our friends of the show list, and read our newsletter. I’ll be sure to drop a note in there when it’s ready.
Michael:
VS Code AMA @ Talk Python [video]
Gunicorn CVE
Talk submissions are now open for both remote and in-person talks at the 2024 PyConZA? The conference will be held on 3 and 4 October 2024 in Cape Town, South Africa. Details are on za.pycon.org.
FlaskCon 2024 will be happening Friday, May 17 inside PyCon US 2024. Call for proposals are now live!
Joke: Debugging with your eyes
4/23/2024 • 24 minutes, 7 seconds
#379 Constable on the debugging case
Topics covered in this episode:
How to Set Up Pre-Commit Hooks A step-by-step guide to installing and configuring pre-commit hooks on your project.
difftastic
Quarto
constable
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of
the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: How to Set Up Pre-Commit Hooks A step-by-step guide to installing and configuring pre-commit hooks on your project.
by Stefanie Molin
Pre-commit hooks are code checks that run as part of the “pre-commit” stage of the git commit process.
If any of these checks fail, git aborts the commit
Sometimes, we need to bypass the hooks temporarily. For these instances, we can pass the --no-verify option when we run git commit
Brian #2: difftastic
Found this a couple years ago, but really using it a lot now.
Excellent structurally diff tool that compares code based on syntax, not line by line.
Michael #3: Quarto
via Mathias Johansson
An open-source scientific and technical publishing system
Transforming a notebook into a pdf / HTML / MS Word / ePub with minimal effort, or even all formats at once.
Author using Jupyter notebooks or with plain text markdown in your favorite editor.
Write using Pandoc markdown, including equations, citations, crossrefs, figure panels, callouts, advanced layout, and more.
Brian #4: constable
“inserts print statements directly into the AST at runtime “
“If you find yourself aimlessly adding print statements while debugging your code, this is for you. !”
Add decorators like @constable.trace('a', 'b') to functions and you’ll get nice output showing when and how a and b changed.
see also icecream for another fun debugging with print project.
Extras
Brian:
pointers being added to the standard library
A couple weeks old, but still worth covering
Guido’s take on adding this, "Why the hell not?"
Michael:
Python 3.12.3 is out
Joke: Hugo SciFi Award
4/16/2024 • 20 minutes, 13 seconds
#378 Python is on the edge
Topics covered in this episode:
pacemaker - For controlling time per iteration loop in Python.
PyPI suspends new user registration to block malware campaign
Python Project-Local Virtualenv Management Redux
Python Edge Workers at Cloudflare
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Brian #1: pacemaker - For controlling time per iteration loop in Python.
Brandon Rohrer
Good example of a small bit of code made into a small package.
With speedups to dependencies, like with uv, for example, I think we’ll see more small projects.
Cool stuff
Great README, including quirks that need to be understood by users.
“If the pacemaker experiences a delay, it will allow faster iterations to try to catch up. Heads up: because of this, any individual iteration might end up being much shorter than suggested by the pacemaker's target rate.”
Nice use of time.monotonic()
deltas are guaranteed to never go back in time regardless of what adjustments are made to the system clock.
Watch out for
pip install pacemaker-lite
NOT pacemaker
pacemaker is taken by a package named PaceMaker with a repo named pace-maker, that hasn’t been updated in 3 years. Not sure if it’s alive.
No tests (yet). I’m sure they’re coming. ;)
Seriously though, Brandon says this is “a glorified snippet”. And I love the use of packaging to encapsulate shared code. Realistically, small snippet like packages have functionality that’s probably going to be tested by end user code.
And even if there are tests, users should test the functionality they are depending on.
Michael #2: PyPI suspends new user registration to block malware campaign
Incident Report for Python Infrastructure
PyPi Is Under Attack: Project Creation and User Registration Suspended — Here’s the details
I hate medium, but it’s the best details I’ve found so far
Brian #3: Python Project-Local Virtualenv Management Redux
Hynek
Concise writeup of how Hynek uses various tools for dealing with environments
Covers (paren notes are from Brian)
In project .venv directories
direnv for handling .envrc files per project (time for me to try this again)
uv for pip and pip-compile functionality
Installing Python via python.org
Using a .python-version-default file (I’ll need to play with this a bit)
Works with GH Action setup-python. (ok. that’s cool)
Some fish shell scripting
Bonus tip on using requires-python in .pyproject.toml and extracting it in GH actions to be able to get the python exe name, and then be able to pass it to Docker and reference it in a Dockerfile. (very cool)
Michael #4: Python Edge Workers at Cloudflare
What are edge workers?
Based on workers using Pyodide and WebAssembly
This new support for Python is different from how Workers have historically supported languages beyond JavaScript — in this case, we have directly integrated a Python implementation into workerd, the open-source Workers runtime.
Python Workers can import a subset of popular Python packages including FastAPI, Langchain, numpy
Check out the examples repo.
Extras
Michael:
LPython follow up from Brian Skinn
Featured on Python Bytes badge
A little downtime, thanks for the understanding
We were rocking a 99.98% uptime until then. :)
Joke:
C++ is not safe for people under 18
Baseball joke
4/9/2024 • 31 minutes, 24 seconds
#377 A Dramatic Episode
Topics covered in this episode:
justpath
xz back door
LPython
dramatic
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Finally, if you want an artisanal, hand-crafted digest of every week of
the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.
Michael #1: justpath
Inspect and refine PATH environment variable on both Windows and Linux.
Raw, count, duplicates, invalids, corrections, excellent stuff.
Check out the video
Brian #2: xz back door
In case you kinda heard about this, but not really.
Very short version:
A Microsoft engineer noticed a performance problem with ssh and tracked it to a particular version update of xz.
Further investigations found a multi-year installation of a fairly complex back door into the xz by a new-ish contributor. But still contributing over several years. First commit in early 2022.
The problem is caught. But if it had succeeded, it would have been bad.
Part of the issue of how this happened is due to having one primary maintainer on a very widely used tool included in tons-o-Linux distributions.
Some useful articles
Everything I Know About the XZ Backdoor - Evan Boehs - recommended read
Don’t think your affected? Think again if you use homebrew, for example:
Update and upgrade Homebrew and xz versions
Notes
Open source maintenance burnout is real
Lots of open source projects are maintained by unpaid individuals for long periods of time.
Multi-year sneakiness and social bullying is pretty hard to defend against.
Handing off projects to another primary maintainer has to be doable.
But now I think we need better tools to vet contributors.
Maybe? Or would that just suppress contributions?
One option to help with burnout:
JGMM, Just Give Maintainers Money: Software Needs To Be More Expensive - Glyph
Michael #3: LPython
LPython aggressively optimizes type-annotated Python code. It has several backends, including LLVM, C, C++, and WASM.
LPython’s primary tenet is speed.
Play with the wasm version here: dev.lpython.org
Still in alpha, so keep that in mind.
Brian #4: dramatic
Trey Hunner
More drama in the software world. This time in the Python.
Actually, this is just a fun utility to make your Python output more dramatic.
More fun output with terminaltexteffects
suggested by Allan
Extras
Brian:
Textual how has a new inline feature in the new release.
Michael:
My keynote talk is out: The State of Python in 2024
Have you browsed your github feed lately?
3.10, 3.9, 3.8 security updates
Joke: Definition of terms
4/2/2024 • 32 minutes, 55 seconds
#376 Every dunder method in a Python Lockbox
Topics covered in this episode:
🤖 On Robots.txt
niquests
Every dunder method in Python
Lockbox
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: 🤖 On Robots.txt
Jeff Triplett
“In theory, this file helps control what search engines and AI scrapers are allowed to visit, but I need more confidence in its effectiveness in the post-AI apocalyptic world.”
Resources to get started
Block the Bots that Feed “AI” Models by Scraping Your Website
Go ahead and block AI web crawlers
Dark Visitors
Django
Add robots.txt to a Django website
How to add a robots.txt to your Django site
Hugo
Hugo robots.txt
Podcast questions:
Should content creators block AI from our work?
Should’t we set up a standard way to do this?
I still haven’t found a way to block GitHub repositories.
Is there a way?
Licensing is one thing (not easy), but I don’t think any bots respect any protocol for repos.
Michael #2: niquests
Requests but with HTTP/3, HTTP/2, Multiplexed Connections, System CAs, Certificate Revocation, DNS over HTTPS / TLS / QUIC or UDP, Async, DNSSEC, and (much) pain removed!
Niquests is a simple, yet elegant, HTTP library. It is a drop-in replacement for Requests, which is under feature freeze.
See why you should switch: Read about 10 reasons why
Brian #3: Every dunder method in Python
Trey Hunner
Sure, there’s __repr__(), __str__(), and __init__(), but how about dunder methods for:
Equality and hashability
Orderability
Type conversions and formatting
Context managers
Containers and collections
Callability
Arithmetic operators
… and so much more … even a cheat sheet.
Michael #4: Lockbox
Lockbox is a forward proxy for making third party API calls.
Why? Automation or workflow platforms like Zapier and IFTTT allow "webhook" actions for interacting with third party APIs.
They require you to provide your third party API keys so they can act on your behalf. You are trusting them to keep your API keys safe, and that they do not misuse them.
How Lockbox helps: When a workflow platform needs to make a third party API call on your behalf, it makes a Lockbox API call instead. Lockbox makes the call to the third party API, and returns the result to the workflow platform.
Extras
Brian:
Django: Join the community on Mastodon - Adam Johnson
No maintenance intended - Sent in from Kim van Wyk
Michael:
US sues Apple
Good video on pluses and minuses
The hot water just the day before [and this one]
https://9to5mac.com/2024/03/25/app-store-proposals-rejected/
PyPI Support Specialist job
VS Code AMA, please submit your question here
PyData Eindhoven 2024 has a date and open CFP
Joke: Windows Certified
3/26/2024 • 32 minutes, 4 seconds
#375 Pointing at Countries
Topics covered in this episode:
pycountry
Does Python have pointers?
ingestr
Make your terminal nice
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: pycountry
A Python library to access ISO country, subdivision, language, currency and script definitions and their translations.
pycountry provides the ISO databases for the standards:
639-3 Languages
3166 Codes for representation of names of countries and their subdivisions
3166-1 Countries
3166-3 Deleted countries
3166-2 Subdivisions of countries
4217 Currencies
15924 Scripts
Brian #2: Does Python have pointers?
Ned Batchelder
Turns out, this is really the description of “what’s a variable in Python?” that helps to make sense of the “variables as names” model in Python, especially for people coming from languages that use pointers a lot.
You can use id() to find out what a variable points to
You just can’t do the reverse of access it given an id.
There’s no “dereference” operator.
See also Python Names and Values, also by Ned
Should be required reading/viewing for all Python curriculum.
Michael #3: ingestr
ingestr is a command-line application that allows ingesting or copying data from any source into any destination database.
Works on both MongoDB and Postgres and many more.
incremental loading: append, merge or delete+insert
Brian #4: Make your terminal nice
David Lord
David’s switched to Fish and Starship
I tried switching to Fish several times, and I guess I’m good with zsh.
Although I admire the brave comic sans motto: “Finally, a command line shell for the 90s”
But I’m finally ready for Starship, and it takes almost no time to set up
Plus it’s fast. (Has it always been Rust?)
Extras
Brian:
Doing some groundwork for a SaaS project, using SaaS Pegasus
I just talked with Cory from Pegasus for an upcoming PythonTest episode
I haven’t decided whether to save up SaaS episodes for one big series, or spread them out.
But mostly I’m excited to get my project started.
Michael:
Excellent video about “cloud exit”
uv - The Next Evolution in Python Packages?
Python 3.13 a5
Target’s Open Source Fund via Pat Decker
Joke: Anti-social engineer
3/19/2024 • 24 minutes, 56 seconds
#374 Climbing the Python Web Mountain
Topics covered in this episode:
6 ways to improve the architecture of your Python project (using import-linter)
Mountaineer
Why Python's Integer Division Floors
Hatchet
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: 6 ways to improve the architecture of your Python project (using import-linter)
Piglei
Using import-linter to
define architectural layers
check to make sure imports don’t violate (import from upper layers)
can also check for more contracts, such as
forbidden - disallow a specific from/to import
independence - list of modules that shouldn’t import from each other
Fixing violations
a process introduced to set exceptions for each violation in a config file
then fix violations 1 at a time (nice approach)
use the whole team if you can
Common methods for fixing dependency issues
Merging and splitting modules
Dependency Injection, including using protocols to keep type hints without the need to import just for types
Use simpler dependency types
Delaying function implementations
module global methods set by caller, or adding a simple plugin/callback system
Configuration driven
Setting import statements in a config file and using import_string() at runtime
Replace function calls with event-driven approaches
Michael #2: Mountaineer
Mountaineer is a batteries-included web framework for Python and React.
Mountaineer focuses on developer productivity above all else, with production speed a close second.
📝 Typehints up and down the stack: frontend, backend, and database
🎙️ Trivially easy client[HTML_REMOVED]server communication, data binding, and function calling
🌎 Optimized server rendering for better accessibility and SEO
🏹 Static analysis of web pages for strong validation: link validity, data access, etc.
🤩 Skip the API or Node.js server just to serve frontend clients
Brian #3: Why Python's Integer Division Floors
Guido van Rossum
Integer division always floors (toward negative infinity) instead of truncating. (C truncates)
5//2 → 2
-5//2 → -3
5//-2 → -3
Reason,
For nice mathematical relationships with // and % (modulo).
a//b = quotient (q), a%b = remainder (r)
such that b*q + r = a, and 0 <= r < b
This works for both positive and negative a values
For negative b, the second rule has to change to 0 >= r > b
If you truncate (like C does), you have to use abs(r) for the first rule to work.
Theory of why C doesn’t do it this way: Probably a hardware limitation at the time when C was designed, due to “sign + magnitude” integers instead of modern two’s compliment integers.
Michael #4: Hatchet
Hatchet is a distributed, fault-tolerant task queue which replaces traditional message brokers and pub/sub systems.
It’s built to solve problems like concurrency, fairness, and durability
Concurrency, Fairness, and Rate limiting: Enable FIFO, LIFO, Round Robin, and Priority Queues with built-in strategies to avoid common pitfalls.
Architected for Resiliency: Customizable retry policies and built-in error handling to recover from transient failures.
Extras
Brian:
Charlie Marsh on uv in PythonTest episode 216
Michael:
Build An Audio AI App Course [free!]
Rock Solid Python with Python Typing Course
Coolio
Joke: Breaking Prod
3/11/2024 • 32 minutes, 50 seconds
#373 Changing Directories
Topics covered in this episode:
zoxide
Smart CLIs with Typer
Python recommended officially by the US Government
Textual tutorials at Mouse vs Python
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: zoxide
zoxide is a smarter cd command, inspired by z and autojump.
It remembers which directories you use most frequently, so you can "jump" to them in just a few keystrokes.
zoxide works on all major shells and platforms.
Brian #2: Smart CLIs with Typer
Rahul Pai
Lots of TILs here, even though I’ve been using Typer for years.
Examples of
Auto-detection of arguments and types based on type hints
Help text is a smidge clunkier
Prompting for missing arguments
Defaulting to an enviromental variable for missing args
Print help if no args given
Explicit app and subcommands with a comparison to argparse
Reusable commands with result_callback
Several topics covered in comparison with argparse
See also Testing argparse Applications
Michael #3: Python recommended officially by the US Government
The US government explicitly recommends memory safe languages.
Python is one of them
The comparison to big tech by Samuel is interesting
Brian #4: Textual tutorials at Mouse vs Python
Mike Driscoll
Most recently Creating a Modal Dialog For Your TUIs in Textual
Textualize already has some pretty great documentation at textual.textualize.io
But it’s cool to see some different tutorials on it.
Extras
Brian:
Is UV the FUTURE of Python PACKAGING? 🐍📦 - Hynek
Nice context on how uv fits into all of the existing packaging challenges and some hope for the future.
venmo feed is public by default
Michael:
ngrok Python SDK
Djangonauts on Talk Python
Maybe just a new case and battery for your phone?
Joke: Ship it!
3/5/2024 • 26 minutes, 33 seconds
#372 uv - an impressive pip alternative
Topics covered in this episode:
uv: Python packaging in Rust
jpterm
Everything You Can Do with Python's textwrap Module
HTML First
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
First, we are likely skipping next week folks. I’ll be at PyCon Philippines.
Brian #1: uv: Python packaging in Rust
Suggested by Collin Sullivan
“uv is designed as a drop-in replacement for pip and pip-tools”
Intended to support the pip and pip-tools APIs, just use uv pip instead.
Oh yeah, also replaces venv and virtualenv.
And it’s super zippy, as you would expect.
I’m still getting used to it
uv pip venv didn’t have --prompt at first. But that’s fixed. should get released soon.
first thing I tried
uv pip install ./ and uv pip install pytest
second. worked awesome
uv pip list
third thing I tried
not there either, but uv pip freeze is similar.
Issue already filed
Seriously, I’m excited about this. It’s just that it seems I wasn’t the target workflow for this.
See also
tox-uv - speed up tox with uv
[rye](https://lucumr.pocoo.org/2024/2/15/rye-grows-with-uv/) from Armin Ronacher, will be supported by Astral
- MK:
Switched to this for dev. It’s excellent.
For some reason, doesn’t work on Docker?
From Henry
Michael #2: jpterm
via David Brochart
jpterm is a JupyterLab-like environment running in the terminal.
What sets jpterm apart is that it builds on the shoulders of giants, one of which is Textual.
It is designed similarly to JupyterLab, where everything is a plugin.
Brian #3: Everything You Can Do with Python's textwrap Module
Martin Heinz
Nice quick demo of one of my favorite builtin modules.
Features
shorten text and insert placeholders
wrap can split lines to the same length
but can also just split a string into equal chunks for batch processing
TextWrapper class does all sorts of fancy stuff.
dedent is my fave. Awesome for including a multiline string in a test function as an expected outcome.
Michael #4: HTML First
HTML First is a set of guidelines for making it easier, faster and more maintainable to build web software
Principles
Leveraging the default capabilities of modern web browsers.
Leveraging the extreme simplicity of HTML's attribute syntax.
Leveraging the web's ViewSource affordance.
Practices
Prefer Vanilla approaches
Use HTML attributes for styling and behaviour
Use libraries that leverage HTML attributes
Avoid Build Steps
Prefer Naked HTML
Be View-Source Friendly
Extras
Brian:
pytest 8.0.1 released. Fixes the parametrization order reversal I mentioned a couple episodes ago, plus some other fixes.
Learn about dependency injection from Hynek
If you want to jump into some Rust to help speed up Python tools, maybe check out yarr.fyi
I just interviewed Nicole, the creator, for Python Test, and this looks pretty cool
Her episode should come out in a couple of weeks.
Ramping up more interviews for Python People. So please let me know if you’d like to be on the show or if you have suggestions for people you’d like me to interview.
Also, I know this is weird, some people are still on X, and not like “didn’t close their account when they left”, but actually still using it. This is ironically a reverse of X-Files. “I don’t want to believe”. However, I’ve left my account open for those folks. I check it like twice a month. But eventually I’ll see it if you DM me. But really, there are easier ways to reach me.
Michael:
PyData Pittsburg CFP
Wyden: Data Broker Used Abortion Clinic Visitor Location Data To Help Send Targeted Misinformation To Vulnerable Women
SciPy 2024 - Call for Proposals
Joke: Yeti tumbler
2/20/2024 • 34 minutes, 23 seconds
#371 Python in a Crate
Topics covered in this episode:
AppleCrate
One way to package Python code right now
Flask8 but why?
Extra, Extra, Extra
Extras
Joke
Watch on YouTube
About the show
Sponsored by ScoutAPM: pythonbytes.fm/scout
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: AppleCrate
By Rhet Turnbull (from Building macOS Apps episode)
AppleCrate is a tool for creating native macOS installers for your command line tools.
It's useful for creating installers for command line tools written in any language.
Tools written in interpreted languages like Python will need to be first processed with a tool like pyinstaller to create a standalone executable.
AppleCrate uses Jinja2 templates to generate the files required for the installer. This allows you to use template variables in your files or command line parameters to customize the installer.
Brian #2: One way to package Python code right now
Ned Batchelder
An example repo with all the parts for package
A lot of discussion and what to think about in the README (unfortunately rst and not md, but we can’t have everything)
Includes
pyproject.toml
dev-requirements.txt
README.rst
Makefile
LICENSE.txt
.bitignore
.editorconfig
see https://editorconfig.org
Shout out to to Packaging Python Projects on python.org, which is pretty good
Michael #3: Flask8 but why?
Ihor Kalnytskyi: Something I really like about #ruff, a new tool for both linting and formatting in the #python ecosystem. You can literally pick any lint rule it supports and see both reasoning and examples.
Ruff supports over 700 lint rules, many of which are inspired by popular tools like Flake8, isort, pyupgrade, and others.
Brian #4: Extra, Extra, Extra
Flat.app
kinda like trello, etc. but a very simple interface that makes it pretty easy to use
tosdr.org
Terms of Service; Didn’t Read
Kind of a wikipeda way to summarize the terms of service of different web services, and give them ratings/grades
Why I write
I talked about blogging more last episode. Here’s a cool write-up by Sheena O'Connell
reasons
to remember
to refine my thinking
to impact
to get through hard times
to connect
Three pytest Features You Will Love
Helen Scott at JetBrains/PyCharm
Fixtures, Markers, Parametrize
Plus shoutouts to my course and book
Extras
Brian:
Wikipedia List of common misconceptions - just for fun
Ear Trumpet Labs (a Potland Company) Edwina mic - just something on my wish list
Michael
Mozilla Monitor
Python 3.12.2
Upgraded all the Python apps (11 of them) in about 2 minutes and one command
Got a Vision Pro? Try the Talk Python Courses app
Great video event: Data Doodling with Martina Pugliese
Joke: Free Tier
2/13/2024 • 36 minutes, 4 seconds
#370 Your Very Own Heroku
Topics covered in this episode:
Dokku
Summary of Major Changes Between Python Versions
How to check Internet Speed via Terminal? speedtest-cli
Blogs: We all should blog more
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Dokku
An open source PAAS alternative to Heroku.
Dokku helps you build and manage the lifecycle of applications from building to scaling.
Powered by Docker, you can install Dokku on any hardware.
Once it's set up on a host, you can push Heroku-compatible applications to it via Git.
Rich plug in architecture.
Brian #2: Summary of Major Changes Between Python Versions
Nicholas Hairs
Changes between versions & Tools & utilities to help with switching
Hopefully you’re already at least at 3.8, but come on, 3.11 & 3.12 are so fun!
Useful things
pyupgrade can automatically upgrade code base
(However, I frequently just upgrade and run tests and let my old code be as-is until it bugs me. - Brian)
black checks pyproject.toml requires-python setting and uses version specific rules.
Versions (way more highlights listed in the article)
3.8
Assignment expressions := walrus
f"{variable=}" now works
3.9
Typing has built in generics like dict[], so no more from typing import Dict
Dict union operator
Strings can removeprefix and removesuffix
3.10
Structural pattern matching match/case
Typing: Union using pipe |
Dataclasses support slots=True and kw_only=True
3.11
tomllib included as a standard TOMP parser
Exception groups
Exception Notes add_note()
Typing: A Self type
Star unpacking expressions allowed in for statements: for x in *a, *b:
3.12
f-strings can re-use quotes
Typing: better type parameter syntax
Typing: @override decorator ensures a method being overridden by a child class actually exists.
Michael #3: How to check Internet Speed via Terminal? speedtest-cli
Command line interface for testing internet bandwidth using speedtest.net
Just pipx install speedtest-cli
Has a Python API too
Brian #4: Blogs: We all should blog more
Jeff Triplett is attempting one post per day in February
Feb 1: Choosing the Right Python and Django Versions for Your Projects
Feb 2: My First Mac
Which also links to a quite interesting Personal: Default Apps 2023
Feb 3: What’s Your Go-to Comfort Media? [rough cut]
Feb 4: The Django apps I actually use (rough cut)
Feb 5: How to test with Django and pytest fixtures
Need ideas?
Check out Build an idea bank and never run out of blog ideas
Not using AI? Thanks. We appreciate that.
Maybe tag it as Not By AI
Extras
Brian:
If upgrading to pytest 8, be aware that running individual tests with parametrization will result in a reverse order.
It shouldn’t matter. You shouldn’t be depending on test order.
But it was surprising to me.
Issue has been logged
Michael:
Orbstack follow up
Joke: White Lies
2/6/2024 • 36 minutes, 35 seconds
#369 The Readability Episode
Topics covered in this episode:
Granian
pytest 8 is here
Assorted Docker Goodies
New GitHub Copilot Research Finds 'Downward Pressure on Code Quality'
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Granian
via Andy Shapiro and Bill Crook
A Rust HTTP server for Python applications.
Granian design goals are:
Have a single, correct HTTP implementation, supporting versions 1, 2 (and eventually 3)
Provide a single package for several platforms
Avoid the usual Gunicorn + uvicorn + http-tools dependency composition on unix systems
Provide stable performance when compared to existing alternatives
Could use better logging
But making my own taught me maybe I prefer that!
Originates from the Emmett framework.
Brian #2: pytest 8 is here
Improved diffs:
Very verbose -vv is a colored diff, instead of a big chunk of red.
Python code in error reports is now syntax-highlighted as Python.
The sections in the error reports are now better separated.
Diff for standard library container types are improved.
Added more comprehensive set assertion rewrites for comparisons other than equality ==, with the following operations now providing better failure messages: !=, <=, >=, <, and >.
Improvements to -r for xfailures and xpasses
Report tracebacks for xfailures when -rx is set.
Report captured output for xpasses when -rX is set.
For xpasses, add - in summary between test name and reason, to match how xfail is displayed.
This one was important to me. Massively helps when checking/debugging xfail/xpass outcomes in CI. Thanks to Fabian Sturm, Bruno Oliviera, and Ran Benita for help to get this release.
Lots of other improvements
See full changelog for all the juicy details. And then upgrade and try it out!
pip install -U pytest
Michael #3: Assorted Docker Goodies
OrbStack
Say goodbye to slow, clunky containers and VMs
OrbStack is the fast, light, and easy way to run Docker containers and Linux. Develop at lightspeed with our Docker Desktop alternative.
Podman
Podman is an open source container, pod, and container image management engine. Podman makes it easy to find, run, build, and share containers.
Manage containers (not just Podman.)
Podman Desktop allows you to list, view, and manage containers from multiple supported container engines* in a single unified view.
Gain easy access to a shell inside the container, logs, and basic controls.
Works on Podman, Docker, Lima, kind, Red Hat OpenShift, Red Hat OpenShift Developer Sandbox.
CasaOS
Your Personal Cloud OS.
Community-based open source software focused on delivering simple personal cloud experience around Docker ecosystem.
Also have the ZimaCube hardware (Personal cloud. Re-invented.)
Brian #4: New GitHub Copilot Research Finds 'Downward Pressure on Code Quality'
David Ramel
Regarding “…the quality and maintainability of AI-assisted code compared to what would have been written by a human.”
Q: "Is it more similar to the careful, refined contributions of a Senior Developer, or more akin to the disjointed work of a short-term contractor?"
A: "We find disconcerting trends for maintainability. Code churn -- the percentage of lines that are reverted or updated less than two weeks after being authored -- is projected to double in 2024 compared to its 2021, pre-AI baseline. We further find that the percentage of 'added code' and 'copy/pasted code' is increasing in proportion to 'updated,' 'deleted,' and 'moved 'code. In this regard, AI-generated code resembles an itinerant contributor, prone to violate the DRY-ness [don't repeat yourself] of the repos visited."
Extras
Brian:
Did I mention pytest 8? Just pip install -U pytest today
And if you want to learn pytest super fast, check out The Complete pytest Course or grab a copy of the book, Python Testing with pytest
Michael:
I’d like to encourage people to join our mailing list. We have some fun plans and some of them involve our newsletter. It’s super private, no third parties, no spam and is based on my recent Docker and Listmonk work.
Big release for Pydantic, 2.6.
New essay: Use Custom Search Engines Way More
Joke:
Pushing to main
Junior vs Senior engineer
1/30/2024 • 34 minutes, 44 seconds
#368 That episode where we just ship open source
Topics covered in this episode:
Syntax Error #11: Debugging Python
umami and umami-analytics
pytest-suite-timeout
Listmonk and (py) listmonk
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Syntax Error #11: Debugging Python
Juhis
Issue 11 of a fun debugging newsletter from Juhis
Debugging advice
mindeset
take a break
adopt a process
talk to a duck
tools & techniques
print
snoop
debuggers
Django debug toolbar & Kolo for VS Code
Michael #2: umami and umami-analytics
Umami makes it easy to collect, analyze, and understand your web data — while maintaining visitor privacy and data ownership.
umami-analytics is a client for privacy-preserving, open source Umami analytics platform based on httpx and pydantic.
Core features
➕ Add a custom event to your Umami analytics dashboard.
🌐 List all websites with details that you have registered at Umami.
🔀 Both sync and async programming models.
⚒️ Structured data with Pydantic models for API responses.
👩💻 Login / authenticate for either a self-hosted or SaaS hosted instance of Umami.
🥇Set a default website for a simplified API going forward.
Brian #3: pytest-suite-timeout
While recording Python Test 213 : Repeating Tests
I noted that pytest-repeat doesn’t have a timeout, but pytest-flakefinder does.
And perhaps I should add a timeout to pytest-repeat
But also, maybe there’s other places I’d like a timeout, not just with repeat, but often with other parametrizations and even parametrize matrices.
So, pytest-suite-timeout is born
But Why not pytest-timeout? asks Mike Felder
timeout is only timeouts per test, and it isn’t always graceful
suite-timeout is for the full suite, and only times out between tests.
so, you could use both
Michael #4: Listmonk and (py) listmonk
Listmonk
Self-hosted newsletter and mailing list manager (think mailchimp)
Built on Go and Vue
Backed by a company charing for this service as SaaS
Still requires a mail infrastructure backend (I’m using Sendgrid)
listmonk (on PyPI)
API Client for Python
Created by Yours Truly
I tried 4 other options first, they were all bad in their own way.
Features:
➕Add a subscriber to your subscribed users.
🙎 Get subscriber details by email, ID, UUID, and more.
📝 Modify subscriber details (including custom attribute collection).
🔍 Search your users based on app and custom attributes.
🏥 Check the health and connectivity of your instance.
👥 Retrieve your segmentation lists, list details, and subscribers.
🙅 Unsubscribe and block users who don't want to be contacted further.
💥 Completely delete a subscriber from your instance.
📧 Send transactional email with template data (e.g. password reset emails).
These pair well in my new docker cluster infrastructure
Calls to the API from a client app (e.g. Talk Python Training) are basically loopback on the local docker bridge network.
Extras
Michael:
Every github repo that has “releases” has a releases RSS feed, e.g. Umami
Kolo Django + VS Code
Warp Terminal on linux
bpytop and btop - live server monitoring
Joke: The cloud, visualized
1/23/2024 • 32 minutes, 18 seconds
#367 A New Cloud Computing Paradigm at Python Bytes
Topics covered in this episode:
Leaving the cloud
PEP 723 - Inline script metadata
Flet for Android
harlequin: The SQL IDE for Your Terminal.
Extras
Joke
Watch on YouTube
About the show
Sponsored by Bright Data : pythonbytes.fm/brightdata
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Leaving the cloud
Also see Five values guiding our cloud exit
We value independence above all else.
We serve the internet.
We spend our money wisely.
We lead the way.
We seek adventure.
And We stand to save $7m over five years from our cloud exit
Slice our new monster 192-thread Dell R7625s into isolated VMs
Which added a combined 4,000 vCPUs with 7,680 GB of RAM and 384TB of NVMe storage to our server capacity
They created Kamal — Deploy web apps anywhere
A lot of these ideas have changed how I run the infrastructure at Talk Python and for Python Bytes.
Brian #2: PEP 723 - Inline script metadata
Author: Ofek Lev
This PEP specifies a metadata format that can be embedded in single-file Python scripts to assist launchers, IDEs and other external tools which may need to interact with such scripts.
Example:
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "requests&lt;3",
# "rich",
# ]
# ///
import requests
from rich.pretty import pprint
resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])
Michael #3: Flet for Android
via Balázs
Remember Flet?
Here’s a code sample (scroll down a bit).
It’s amazing but has been basically impossible to deploy.
Now we have Android.
Here’s a good YouTube video showing the build process for APKs.
Brian #4: harlequin: The SQL IDE for Your Terminal.
Ted Conbeer & other contributors
Works with DuckDB and SQLite
Speaking of SQLite
Jeff Triplett and warnings of using Docker and SQLite in production
Anže’s post
and and article: Django, SQLite, and the Database is Locked Error
Extras
Brian:
Recent Python People episodes
Will Vincent
Julian Sequeira
Pamela Fox
Michael:
PageFind and how I’m using it
When "Everything" Becomes Too Much: The npm Package Chaos of 2024
Essay: Unsolicited Advice for Mozilla and Firefox
SciPy 2024 is coming to Washington
Joke: Careful with that bike lock combination code
1/16/2024 • 36 minutes, 21 seconds
#366 Put It In The Backlog
Topics covered in this episode:
Python 3.13 gets a JIT
UniDep - Unified Conda and Pip Dependency Management
Don’t Start Pull Requests from Your Main Branch
instld: The simplest package management
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Python 3.13 gets a JIT
Anthony Shaw
Great article that walks through JIT concepts with a small example as if you were writing a parser in Python instead of C.
Covers
What is a JIT?
What is a copy-and-patch JIT? and Why?
How does the Python JIT work?
Is it faster?
This is a building block to future improvements
Michael #2: UniDep - Unified Conda and Pip Dependency Management
🔄 Single requirements.yaml for both #Conda & #Pip.
⚙️ Works with pyproject.toml & setup.py.
🏢 Perfect for monorepos.
🔒 Create consistent conda-lock files for multiple projects.
🌍 Platform-specific support.
🚀 unidep install for easy setup.
Full source page.
Brian #3: Don’t Start Pull Requests from Your Main Branch
Hynek Schlawack
When contributing to other users’ repositories, always start a new branch in your fork.
Reasons to not use main
Forces you to only have one change in progress
Merges will generate conflicts and you can’t pull from that branch anymore. Need to kill the fork and start over
If the target repo has branch protection on, then maintainers can’t push to your branch.
Hynek also provides a way to fix things if you’ve already started your changes on a main branch fork.
Michael #4: instld: The simplest package management
Thanks to this package, it is very easy to manage the lifecycle of packages.
⚡ Run your code without installing libraries.
⚡ You can use 2 different versions of the same library in the same program.
⚡ You can use incompatible libraries in the same project, as well as libraries with incompatible/conflicting dependencies.
⚡ It's easy to share written scripts. The script file becomes self-sufficient - the user does not need to install the necessary libraries.
⚡ The library does not leave behind "garbage". After the end of the program, no additional files remain in the system.
Extras
Brian:
The Complete pytest Course is now actually complete
Although updates will happen when and if necessary as pytest/Python changes.
To celebrate, use code 2024 in January for 10% off any pricing option.
More episodes of Python People and Python Test on the way now
That course took up a lot of my time in late 2023
Just released an episode with Will Vincent and Python Test will have a new episode this week and for the foreseeable future.
Let me know if you want to be on Python People or Python Test
Michael:
Hatch follow up: Great coverage of Hatch v1.8.0! One small correction: only the binaries for Hatch are signed with the certificate from the PSF. - Ofek
PyPI new user registration temporarily suspended
Pagefind and how I’m using it
Talk Python Live: Data Doodles event coming early Feb
New essay: AI Features a Waste of Time?
Joke: Put it in the backlog
1/9/2024 • 32 minutes, 1 second
#365 Inheritance, but not Inheritance!
Topics covered in this episode:
* Hatch v1.8*
svcs: A Flexible Service Locator for Python
Steering Council 2024 Term Election Results
Python protocols. When to use them in your projects to abstract and decoupling
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Hatch v1.8
Hatch now manages installing Python for you.
Hatch can build .app and .exe stand-alone binaries for you
The macOS ones are signed (signed!)
Discussion here
Brian #2: svcs : A Flexible Service Locator for Python
Hynek
A library to help structure and test Python web applications.
“svcs (pronounced services) is a dependency container* for Python. It gives you a central place to register factories for types/interfaces and then imperatively acquire instances of those types with automatic cleanup* and **health checks.”
“Benefits:
Eliminates tons of repetitive boilerplate code,
unifies acquisition* and cleanups of services,
provides full static type safety for them,
simplifies testing through loose coupling,
improves live introspection and monitoring* with **health checks.”
Hynek has started a YouTube channel, and is starting with an explanation of svcs.
Yes, Hynek, we want more videos. I like that it’s not a beginner level.
My request for future videos: just past beginner, and also intermediate level.
There are plenty of basics videos out there, not as many filling the gaps between beginner and production.
Michael #3: Steering Council 2024 Term Election Results
The 2024 Term Python Steering Council is:
Pablo Galindo Salgado
Gregory P. Smith
Emily Morehouse
Barry Warsaw
Thomas Wouters
Full results are available in PEP 8105 .
How do you become a candidate?
Candidates must be nominated by a core team member. If the candidate is a core team member, they may nominate themselves.
Brian #4: Python protocols. When to use them in your projects to abstract and decoupling
Carlos Vecina
“Protocols are an alternative (or a complement) to inheritance, abstract classes and Mixins.”
Understanding interactions between ABC, MixIns and Protocols in Python
With examples
Extras
Brian:
Donations. It’s a decent time of the year to donate to projects that help you
Python Software Foundation
Django Software Foundation
Python Bytes
Also, look for “Sponsor this project” links in GitHub for projects you depend on.
Michael:
Mastodon guidelines (mine):
If you have a picture and description, I’ll probably follow you back
If you have posts that seem relevant +1
If you have a verified webpage +1
If your account is private, won’t. I don’t understand really since private group messages already exist and the profile itself is public.
Speaking of Mastodon. I had a productive conversation with the PSF and others around masks and conferences.
Dropbox spooks users by sending data to OpenAI for AI search features
There was a comment in the above article to the effect of “Once you give your data to a third party (even trusted like Dropbox), you no longer control that data.” That sent me searching and thinking…
sync.com? proton drive (discount code)? nextcloud? filen.io? icedrive.net?
ownCloud’s recent CVE makes me a bit nervous of self-hosted options.
Either way, Cryptomator is very interesting.
Beyond privacy, this got me thinking, just how many hours of dev time have been diverted to add mediocre-at-best AI features to everything?
I’m doing a big digital decluttering and have lots to say on that soon.
Not submitting my talks to PyCascades this year.
But I did submit 3 talks to PyCon US. 🤞
I will be giving the keynote at PyCon Philippines.
Joke: The dream is dead?
12/20/2023 • 34 minutes, 29 seconds
#364 Holy Match-Cases Batman!
Topics covered in this episode:
A Python/Django Advent calendar
Dropbase helps you build internal web apps with Python
Real-world match/case
Extra, extra, extra, so many extras!
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: A Python/Django Advent calendar
James Bennett’s take on an Advent Calendar
“I’m going to try to publish one short blog post each day of Advent 2023, each covering a small but hopefully useful tip or bit of information for Python and/or Django developers”
First post also discusses using enums
A couple cool testing posts
Don’t mock Python’s HTTPX
I didn’t know HTTPX had built in transport mocking, very cool
Test your documentation
doctest discussion
Michael #2: Dropbase helps you build internal web apps with Python
Build fullstack web apps for your internal teams.
Import existing Python scripts
Quickly layer UIs and granular permissions on top.
Turn any SQL SELECT into an admin panel with Smart Tables.
Watch the video for the zen of it.
Freemium model
Brian #3: Real-world match/case
Ned Batchelder
Structural pattern matching example taken from a GitHub bot
Matching nested dictionaries, pulling out bits of data
The examples of not just matching but using case [structure] if [test on component] are neat.
Michael #4: Extra, extra, extra, so many extras!
WAY better DNS with Bunny.net DNS
Terminal Secrets essay
Meet the Supporting Developer in Residence (via Pycoders)
Songs in Python code
BohemianRhapsody.py
MoneyForNothing.py
PyCascades 2024
Project names blocked on PyPI to avoid name collision for downstream free-threaded Python distributions
An Open Letter to the Python Software Foundation
PSF’s official mission
https://discuss.python.org/t/python-3-12-1-now-available/40603
https://discuss.python.org/t/python-3-11-7-is-available/40778
Obfuscated Python winning (via Johannes Lippmann)
Extras
Brian:
Python for VSCode, Dec 2023 release, rolls out better test discovery to everyone.
Forcing pip to use virtualenv
Advent of Code
Joke: Too many open tabs
12/12/2023 • 27 minutes, 9 seconds
#363 DNS Again? It's Always DNS.
Topics covered in this episode:
Fixit 2: Meta’s next-generation auto-fixing linter
FastUI
Mail list / newsletter conversation
CLIs from type hints
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Fixit 2: Meta’s next-generation auto-fixing linter
via Bart Kappenburg
Fixit is dead! Long live Fixit 2 – the latest version of our open-source auto-fixing linter.
Fixit provides a highly configurable linting framework with support for auto-fixes, custom “local” lint rules, and hierarchical configuration, built on LibCST.
Fixit 2 is available today on PyPI.
Created by Meta’s Python Language Foundation team — a hybrid team of both PEs and traditional SWEs — helps own and maintain the infrastructure and tooling for Python.
Interesting comments on this article on Hacker News
I wonder if ruff format was already a thing when Fixit was adopted, whether it would exist?
Brian #2: FastUI
Samuel Colvin
“FastUI is a new way to build web application user interfaces defined by declarative Python code.”
MK: Reminds me of the code matches DOM style of Flutter. See code samples at the end.
Michael #3: Mail list / newsletter conversation
I’ve been tired of Mailchimp for a long time
Raising the prices month over month by $100 several months may be the straw
But what are the options? Lets ask Mastodon:
emailoctopus.com
listmonk.app [self hosted, open source]
keila.io [self/saas, open source]
mailyherald.org [self hosted, open source]
sendportal.io [self hosted, open source]
brevo.com
buttondown.email [django]
zoho.com/campaigns/
sendy.co [use your own bulk emailer (e.g. sendgrid or aws ses)
convertkit.com
mautic.org [open source]
constantcontact.com
getresponse.com
convertkit.com
Brian #4: CLIs from type hints
From Sander76
Pydantic Argparse “is a Python package built on top of pydantic which provides declarative typed argument parsing using pydantic models.”
Clipstick is a “cli-tool based on Pydantic models.”
tyro “is a tool for generating command-line interfaces and configuration objects in Python.”
tyro includes support for dataclasses and attrs in place of Pydantic
Extras
Brian:
Django 5.0 has been released
vim-keybindings-everywhere-the-ultimate-list - submitted by Paul Barry
PythonTest (the podcast formerly known as Test & Code, to be read in an undertone similar to the way one used to say “The artist formerly known as Prince”) has moved form testandcode.com to podcast.pythontest.com
Plus more guests are listed now. I think I’ve gone backwards from current to episode 182. I tried to get my kid to help out, unsuccessfully. May have to hire someone to help. grrr.
Michael:
Essay: Don't Sweat the Ad Blocker Drama
A story: my project this weekend, unify my over 20 domains to one host
Joke: Honest LinkedIn
12/5/2023 • 39 minutes, 1 second
#362 You can deprecate a global variable?
Topics covered in this episode:
Habits of great software engineers
Flask 3.0
Build Conway's Game of Life With Python
polars business
Extras
Joke
Watch on YouTube
About the show
Sponsored by Scout APM
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Habits of great software engineers
As we wind up the year, many people are thinking about goals for the new year.
Here’s a decent list to think about
Focusing beyond the code
Efficiency / Antifragility
Joy of tinkering
Knowing the why
Thinking in systems
Tech detox
The art of approximation
Transferring Knowledge to Other Problems
Making Hard Things Easy
Playing the Long Game
Developing a Code Nose
Strong Opinions loosely held
Michael #2: Flask 3.0
Deprecate the __version__ attribute. Use feature detection, or importlib.metadata.version("flask"), instead. #5230
How do you even do that?
This is news to me:
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[metadata]
name = "your-package-name"
version = "0.1.0"
Remove previously deprecated code. #5223
Brian #3: Build Conway's Game of Life With Python
Leodanis Pozo Ramos
CLI curses version
Nice walk through of breaking the problem into parts.
Michael #4: polars business
It's a plugin for Polars, which allows you to do business day arithmetic.
The big advantage of using this directly (as opposed to converting to pandas/numpy, using their business day tools, and then converting back) is that polars-business fits right in with the Polars lazy API. This means you'll still be able to get the gains from the Polars query optimiser without having to step into eager execution.
All you need to use is it is pip install polars-business
Written in Rust, but end-users doesn't need Rust to run it, Python is all you need.
Extras
Brian:
BLACKFRIDAY code still works for 50% off The Complete pytest Course, Full Course + Community Access, through Nov 30
Also Debugging chapter is up, and it includes a small TDD example.
Michael:
Dear Python Community by Kenneth Reitz
Python 3.13a2 out and Major new features of the 3.13 series, compared to 3.12
Thank you Black Friday supporters.
Joke:
ai vs dev
11/28/2023 • 28 minutes, 10 seconds
#361 Proper way to comment your code!
Topics covered in this episode:
The many shapes and sizes of keyboards
appeal - a CLI framework from Larry Hastings
Graphinate: Data to Graphs
A Disorganized List of Maintainer Tasks
Extras
Joke
Watch on YouTube
About the show
Sponsored by Scout APM
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: The many shapes and sizes of keyboards
Many keyboards discussed
Focus on health and safety (as it should!)
I swear by Microsoft Sculpt Ergonomic (which wasn’t mentioned)
More options still over at Wire Cutter
Brian #2: appeal - a CLI framework from Larry Hastings
“Give your program APPEAL!”
Appeal is a command-line argument processing library for Python, like argparse, optparse, getopt, docopt, Typer, and click. But Appeal takes a refreshing new approach.
Hello World example:
import appeal
app = appeal.Appeal()
@app.command()
def hello(name):
print(f"Hello, {name}!")
app.main()
looks fun, no idea how to test with it “yet”.
But I plan on looking into that.
Michael #3: Graphinate: Data to Graphs
via Eran Rivlis
Graphinate is a python library that aims to simplify the generation of Graph Data Structures from Data Sources.
Write a function to definite the edges as a generator, call materialize
Based on NetworkX
See the github page for visual examples
Brian #4: A Disorganized List of Maintainer Tasks
David Lord
Plus, David Lord, lead maintainer of Flask, Jinja, Click, … on Pallets, also PSF Fellow, has a blog. Neat.
TLDR; Next time you want to ask "When's the next release?", instead look at the project and see where you can start getting involved. The more help maintainers have, the more they can get done.
Long list of stuff David thinks about when maintaining a project.
My list is shorter, but it’s still long, and my projects are tiny in comparison to his
Extras
Brian:
Do you do enough testing? pytest to the Rescue! webinar from this morning
The Complete pytest Course will be 16 chapters, 11 are released, the 12th is recorded and almost released, and the 13th should be next week, … I should be done with all 16 by the end of the year.
Testing argparse Applications
Python Test Podcast episode 109: Testing argparse Applications
Blog post on pythontest.com: Testing argparse Applications
Black Friday sale on The Complete pytest Course
Use code BLACKFRIDAY for 50% off of
The Complete pytest Course, Full Course + Full Access
Michael:
It’s Black Friday at Talk Python
Python 3.13.0 alpha 1 is now available
Python Developers Survey 2023
Joke: The proper way to comment your code!
11/21/2023 • 29 minutes, 39 seconds
#360 Happy Birthday!
Topics covered in this episode:
exclude_also with coverage.py
Writeside
Extra, extra, extra
Chrome not proceeding with Web Integrity API deemed by many to be DRM
Extras
Joke
Watch on YouTube
About the show
Sponsored by Scout APM
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Note: No episode next week. Michael will be at Microsoft Ignite in Seattle.
Happy Birthday to us (7 years old today)!
Brian #1: exclude_also with coverage.py
Interesting exchange between Pamela Fox, Hugo van Kemenade, and myself where we all discover exclude_also, even though it’s been there since February
This is cool because you can exclude common “should I cover this? It’s just for debugging.” kinda stuff, and other “I don’t wanna test that” places.
To exclude code blocks, we can use *# pragma: no cover* in the code.
Or we can list lines in coverage setting with exclude_lines, but you have to also list # pragma: no cover, which is weird.
exclude_also just just right. It leaves all the inline excludes alone, and adds some regexes, and you can even just have one if that’s all you need, like if __name__ == .__main__.:
See coverage docs
Michael #2: Writeside
An IDE for writing the docs
Write, test, build, and publish docs
Docs-as-code out of the box
Doc quality automation: Ensure documentation quality and integrity with 100+ on-the-fly inspections in the editor as well as tests in Live Preview and during build.
Comes as a separate IDE as well as a plugin for PyCharm, etc.
Pricing will be free + paid premium version (like PyCharm), fully free for now
Brian #3: Extra, extra, extra
Welcome Marie Nordin as the new PSF Community Communications Manager
Woohoo!
Pablo Galindo and Łukasz Langa started a podcast, called core.py
Inside look into Python 3.13
Two episodes so far
The first core sprint for 3.13
Details on removing the GIL
regexcrossword
Suggested by Kim van Wyk
actually really great for practicing regex rules
Michael #4: Chrome not proceeding with Web Integrity API deemed by many to be DRM
Google’s premise for the internet:
The Internet should be constructed so that users can be identified, tracked, retargeted (and hence resold). — Google
And privacy is important.
So how do we make both of these work.
FLOCs?
Privacy Sandboxes?
Web Integrity?
No, just no.
How about you sell us ads the same way you surface search results (by what is on the page, not who is visiting it)
Good riddance to this idea you corrupted organization.
What was wrong with Web Integrity? Some comments
Issue #134 calls the idea "absolutely unethical and against the open web."
Issue #113 say they "can't believe this is even proposed."
Issue #127 adds: "Have you ever stopped to consider that you're the bad guys?”
Extras
Brian:
Mock chapter of pytest: working with projects, the 2nd course in The Complete pytest Course series, is recorded and hopefully releasing today. At the very least some time this week.
PyCharm has sent me a bunch of coupon codes for students of The Complete pytest Course.
Sign up for the course and ask me for the code, and I’ll send it to you.
Nov 21 webinar with yours truly: Do You Do Enough Testing? pytest to the Rescue!
Michael:
We Just Gave $500,000 to Open Source Maintainers - Sentry (thank you)
ruff format + pycharm follow up
JetBrains AI is getting very good a commit messages
Add exception handling in background_service.py:
Introduced try-except blocks to handle potential exceptions in the 'pending_jobs', 'start_job_processing', and 'run_pending_job' methods in background_service.py. This change enhances error handling and makes the service more robust by preventing crashes if a job or episode cannot be fetched or if an unknown job action is encountered.
Add assemblyai to requirements and update ruff version:
This commit includes the addition of assemblyai package as part of the requirements.txt file, required to introduce new speech-to-text feature in our application. Ruff version is also updated from 0.1.3 to 0.1.4 due to bug fixes and stability improvements in the new version. Assemblyai also includes dependencies like pydantic and websockets.
GPT4All follow up
Got some nice feedback on my statement on PyCon 2024’s health and safety policy
More I think about it, the more out of touch it seems
Comparisons, no mask requirements for any of:
GitHub Universe - N,NNN? attendees
CES - 180,000 attendees
SXSW - 152,000 attendees
KubeCon - 12,000 attendees
Adobe Summit - 10,000 attendees
Mobile World Conference - 109,500 attendees
DeveloperWeek - 2,000 attendees
Microsoft Ignite - 4,000 attendees
WWDC - unkown
Joke:
The plural of regex is regrets.
11/7/2023 • 35 minutes, 44 seconds
#359 gil--;
Topics covered in this episode:
PyCon 2024 is up?
Ruff formatter is production ready
gil--;
Why is the Django Admin “Ugly”?
Extras
Joke
Watch on YouTube
About the show
Sponsored by Scout APM
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: PyCon 2024 is up?
May 15 - May 23, 2024 - Pittsburgh, Pennsylvania
Conference breakdown:
Tutorials: May 15 - 16, 2024
Main Conference and Online: May 17 - 19, 2024
Job Fair: May 19, 2024
Sprints: May 20 - May 23, 2024
Tickets aren’t on sale yet
Unfortunately, I’m not going (see health and safety guidelines)
Attendance numbers over time on Wikipedia
Brian #2: Ruff formatter is production ready
We reported the alpha release in September
It’s fast, 30x faster than Black
Provides >99.9% compatibility with Black, with a list of known deviations
More configurable
Bundled with ruff, ruff format
Still in Beta, but considered production-ready
Integration extensions for VSCode and PyCharm
Michael #3: gil--;
The Python Steering Council has now formally accepted PEP 703 ("Making the Global Interpreter Lock Optional in CPython")
The global interpreter lock will remain the default for CPython builds and python.org downloads.
A new build configuration flag, --disable-gil will be added to the configure script that will build CPython with support for running without the global interpreter lock.
"In short, the SC accepts PEP 703, but with clear provisio:
that the rollout be gradual and break as little as possible,
that we can roll back any changes that turn out to be too disruptive – which includes potentially rolling back all of PEP 703 entirely if necessary (however unlikely or undesirable we expect that to be)."
Removing the global interpreter lock requires substantial changes to CPython internals, but relatively few changes to the public Python and C APIs.
The implementation changes can be grouped into the following four categories:
Reference counting
Memory management
Container thread-safety
Locking and atomic APIs
Brian #4: Why is the Django Admin “Ugly”?
Vince Salvino
Some great quotes from the article:
"The Django admin is not ugly, rather, no effort was made to make it a beautiful end-user tool.” - Ken Whitesell
“The admin’s recommended use is limited to an organization’s internal management tool. It’s not intended for building your entire front end around.” - Django docs
“The Django admin was built for Phil.” - Jacob Kaplan-Moss
“Even in the 0.9x days we used to have a image that said “Admin: it’s not your app”.” - Curtis Maloney
As Curtis put it, “encouraging people to build their own management interface, and treat admin as a DB admin tool, has saved a lot of people pain... the effort to customise it grows far faster than the payoffs.”
Extras
Brian:
Local Conferences: Big Potential
Michael:
Data Science Jumpstart with 10 Projects course is out!
PSF is X-ed out (or are they?)
GPT4All is pretty excellent
Fosstodon invites from us (expires Nov 7 2023)
Joke: Searching YouTube for bug fixes
11/2/2023 • 43 minutes, 4 seconds
#358 Collecting Shells
Topics covered in this episode:
Django 5.0 beta 1 released
git bash, terminals, and Windows
Mastering Integration Testing with FastAPI
Reuven Learner has been banned for trading in rare animals (Pythons and Pandas)
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Django 5.0 beta 1 released
Django 5.0 release notes
supports Python 3.10, 3.11, 3.12
Facet filters in the admin
Simplified templates for form field rendering
Database-computed default values
Database generated model field
More options for declaring field choices
More Django news
Djangonaut Space now accepting applications for our next contributor mentorship cohort
Take the Django Developers Survey 2023
Michael #2: git bash, terminals, and Windows
See the screenshot
Requires Windows 10
Install the Windows Terminal from the Microsoft Store
Brian #3: Mastering Integration Testing with FastAPI
Alex Jacobs
Some great integration testing techniques
Focused on FastAPI, but relevant to many frameworks.
Mocking authentication
Mocking external APIs
Fun use of parametrize and indirect fixtures for mocking responses.
Mocking MongoDB
Mocking AWS S3
Michael #4: Reuven Learner has been banned for trading in rare animals (Pythons and Pandas)
via Pat Decker
Reuven, like us, teaches Python and Data Sci
Tried to advertise his courses (Python and Pandas courses) on Meta
Got permanently (life-time) banned for selling rare and endangered animals.
Sometimes I really hate these big tech companies
My recent beefs have been with app store reviewers and surveillance-based capitalism
Extras
Brian:
Where did everyone go? - Ned Batchelder
I do feel like we’re more fragmented than before, but I am feeling like we have a community on Mastodon.
reminder that Mastodon has text search now
On Sunday, I released Ch9, Coverage, as part of The Complete pytest course, specifically part of pytest Working with Projects.
It was super fun. I’ve used coverage a lot since writing the book, for example, I demonstrate branch coverage. It’s so much more effective to teach in video than in printed screenshots.
Michael:
Autin shell enhancer by Ellie Huxtable recommended by recommended by Nik
JupyterCon 2023 videos are out
More shells follow up from Teemu Hukkanen for “editor like” features Zsh and Bash
ruff format and strings, aka format.quote-style = "single"
Glyph’s programming your computer talk is up.
Joke: this is what the experts do
10/24/2023 • 35 minutes, 28 seconds
#357 Python 3.7 EOLed, We Hadn't Noticed
Topics covered in this episode:
QuickMacHotKey
Things I’ve learned about building CLI tools in Python
Warp Terminal (referral code)
Python 3.7 EOLed, but I hadn’t noticed
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: QuickMacHotKey
This is a set of minimal Python bindings for the undocumented macOS framework APIs that even the most modern, sandboxing-friendly shortcut-binding frameworks use under the hood for actually binding global hotkeys.
Thinking of updating my urlify menubar app.
Brian #2: Things I’ve learned about building CLI tools in Python
Simon Willison
A cool Cookiecutter starter project, if you like Click.
Conventions and consistency in commands, arguments, options, and flags.
The importance of versioning. Your CLI is an API.
Include examples in --help
Include --help in documentation.
Aside, Typer is also cool, and is built on Click.
Michael #3: Warp Terminal (referral code)
Really nice reimagining of the terminal
Currently macOS only but will be Linux, then Windows
New command section & output section mode
Blocks can be navigated and searched as a single thing (even if it’s 1,000 lines of output)
CTRL+R gives a nice history like McFly I’ve discussed before
Completions into popular CLIs (i.e. git)
Edit like an editor (even you VIM people 🙂 )
Has AI built in too
Free for individuals
If you’re going to give it a try, use my referral I guess?
Brian #4: Python 3.7 EOLed, but I hadn’t noticed
EOL was June 27
I’m still supporting 3.7, as are most projects I work with. But I’m not sure when that will change.
VS Code is deprecating 3.7 support
Why I’m ok with supporting 3.7 for some projects
dataclasses came in with 3.7
from __ future__ import annotations allows the use of union types with X|Y.
example
I’ll probably drop 3.7 as my dependent projects drop it.
Extras
Brian:
pytest-param-scope is an in progress hack to workaround this missing scope.
Runs setup before any param test cases, and teardown after the last one.
Stop defining people by what they’re not: on “non-code contributors” - Josh Simmons
Michael:
OpenAI has unveiled the Beta version of its Python SDK (via Mark Little)
StackOverflow lays off 28% of its staff
Weird follow up of their “what to do if you’re laid off” post from 6 months ago?
Is AI eating into their traffic?
ArsTechnica has thoughts too
Joke:
Define hot
New Zoo exhibit
10/17/2023 • 29 minutes, 6 seconds
#356 Ripping from PyPY
Topics covered in this episode:
Psycopg 3
dacite
RIP: Fast, barebones pip implementation in Rust
Flaky Tests follow up
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Psycopg 3
Psycopg folks recommend starting with 3 for new projects
2 is still actively maintained, but no new features are planned
recommend staying with 2 for legacy projects
Psycopg 3 project
2 vs 3 feature comparison
A few Psycopg 3 highlights
native asyncio support
native support for more Python types (such as Enums) and PostgreSQL types (such as multirange)
Default server-side parameters binding
Allows binary parameters and query results (and text, of course)
Pipeline/batch mode support
Static typing support
Michael #2: dacite
via Raymond Peck
Simple creation of data classes from dictionaries
Dacite supports following features:
nested structures
(basic) types checking
optional fields (i.e. typing.Optional)
unions
forward references
collections
custom type hooks
It's important to mention that dacite is not a data validation library.
Type hooks are interesting too.
Brian #3: RIP: Fast, barebones pip implementation in Rust
list of current and planned features of RIP, the biggest are listed below:
Downloading and aggressive caching of PyPI metadata. (done)
Resolving of PyPI packages using Resolvo. (done)
Installation of wheel files (planned)
Support sdist files (planned)
new project, just a couple weeks old. … “We would love to have you contribute!”
Michael #4: Flaky Tests follow up
by Marwan Sarieddine
I was inspired by the Talk Python podcast on "Taming flaky tests" with Gregory Kapfhammer and Owain Parry so I wrote up an article on my blog titled "How not to footgun yourself when writing tests - a showcase of flaky tests”
Extras
Brian:
Just wrapping up some personal projects, which means…
Python People episodes soon
Python Test episodes soon (but later)
More course chapters coming
Michael:
PyBay 2023 was fun
Switched to Spark Mail, recommended
Dust (what science fiction story telling should be), try:
FTL
Oceanus
Joke:
There are more hydrogen atoms in a single molecule of water than there are stars in the entire Solar System. - mas.to/@SmudgeTheInsultCat/111174610011921264
The Big Rewrite
10/10/2023 • 24 minutes, 13 seconds
#355 Python 3.12 is Out!
Topics covered in this episode:
3.12 is out!
Trouble with virtualenv caching, a tale of 3.12 update
Python Developers Survey 2022 Results
Scientific Python Library Development Guide
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Complete pytest Course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: 3.12 is out!
What’s new
PEP 695, type parameter syntax and the type statement
PEP 692, using TypedDict to annotate **kwargs
PEP 698, typing.override() decorator
PEP 701, f-strings in the grammar
PEP 684, a unique per-interpreter GIL
PEP 669, low impact monitoring
Improved ‘Did you mean …’ suggestions for NameError, ImportError, and SyntaxError exceptions
PEP 688, using the buffer protocol from Python
The pathlib.Path class now supports subclassing
The os module received several improvements for Windows support
A command-line interface has been added to the sqlite3 module
isinstance() checks against runtime-checkable protocols enjoy a speed up of between two and 20 times
The asyncio package has had a number of performance improvements, with some benchmarks showing a 75% speed up.
A command-line interface has been added to the uuid module
Due to the changes in PEP 701, producing tokens via the tokenize module is up to up to 64% faster.
PEP 683, immortal objects
PEP 709, comprehension inlining
Brian #2: Trouble with virtualenv caching, a tale of 3.12 update
Michael #3: Python Developers Survey 2022 Results
I did a “first reactions” video too
Brian #4:Scientific Python Library Development Guide
Announcement and Overview by Henry Schreiner
Extras
Brian:
The Complete pytest Course is now at courses.pythontest.com
Still on Teachable, just with a custom domain
Also, just released Chapter 8 today.
Michael:
Moving to Mona App (was using Ivory) for Mastodon
Making bank on .ai
Vivaldi on iOS
Joke: Thought it would be easy
10/3/2023 • 35 minutes, 15 seconds
#354 Python 3.12 is Coming!
Topics covered in this episode:
logmerger
The third and final Python 3.12 RC is out now
The Python dictionary dispatch pattern
Visualizing the CPython Release Process
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: logmerger
Paul McGuire
logmerger is a TUI for viewing a merged display of multiple log files, merged by timestamp.
Built on textual
Awesome flags:
--output -
to send the merged logs to stdout
--start START and --end END
start and end time to select time window for merging logs
Caveats:
new. no pip install yet. so clone the code or download
perhaps I jumped the gun on covering this, but it’s cool
Michael #2: The third and final Python 3.12 RC is out now
Get your final bugs fixed before the full release
Call to action: We strongly encourage maintainers of third-party Python projects to prepare their projects for 3.12 compatibilities during this phase
How to test.
Discussion on the issue.
Count down until October 2nd, 2023.
Brian #3: The Python dictionary dispatch pattern
I kinda love (and hate) jump tables in C
We don’t talk about dictionary dispatch much in Python, so this is nice, if not dangerous.
Short story: you can store lambdas or functions in dictionaries, then look them up and call them at the same time.
Also, I gotta shout out to the first blogroll I’ve seen in a very long time.
Should we bring back blogrolls?
Michael #4: Visualizing the CPython Release Process
by Seth Larson
Here’s the deal (you should see the image in the article 😉 )
Freeze the python/cpython release branch. This is done using GitHub Branch Protections.
Update the Release Manager's fork of python/cpython.
Run Python release tools (release-tool, blurb, sphinx, etc).
Push diffs and signed tag to Release Manager's fork.
Git tag is made available to experts for Windows and macOS binary installers.
Source tarballs, Windows, and macOS binary installers built and tested concurrently.
6a: Release manager builds the tgz and tar.xz source files for the Python release. This includes building the updates documentation.
6b: Windows expert starts the Azure Pipelines configured to build Python.
6c: macOS Expert builds the macOS installers.
All artifacts (source and binary) are tested on their platforms.
Release manager signs all artifacts using Sigstore and GPG.
All artifacts are made available on python.org.
After artifacts are published to python.org, the git commit and tag from the Release Manager's fork is pushed to the release branch.
Extras
Brian:
The Complete pytest Course, part 2, Ch 7 Testing Strategy went up this weekend.
Only 9 more chapters to go
“Test & Code” → “Python Test”
Full version: “The Python Test Podcast” → “Test & Code” → “Python Test”
Also: “Python (Bytes | People | Test)”
Michael:
If you’re at PyBay, come say “hi”
EuroPython 2023 Videos up
Django + HTMX has a few days of early-bird discount left
Joke: Are you sleeping?
9/26/2023 • 21 minutes, 26 seconds
#353 Hatching Another Episode
Topics covered in this episode:
OverflowAI
Switching to Hatch
Alpha release of the Ruff formatter
What is wrong with TOML?
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python Testing with pytest, full course
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: OverflowAI
Integration of generative AI into our public platform, Stack Overflow for Teams, and brand new product areas, like an IDE integration.
Have a conversation about the search results and proposed answer with GenAI
Coming with IDE integration too.
Check out the video on their page for some more detail than the article.
Brian #2: Switching to Hatch
Oliver Andrich
Hatch has some interesting features
Template built from hatch new myproject includes isolating dev, test, lint virtual environments.
Each env can have scripts
Test matrix ala tox, but possibly easier to express complex matrices.
May not even need tox then, but then now you have hatch.
A way to specify which optional dependencies needed for default environment.
Notes from Brian
One premise is that lots of projects are now using hatch.
I don’t know if that’s true. A quick spot check of a few projects include projects that use hatchling. While hatchling is the back end to hatch, they are not the same. I use hatchling a lot now, but haven’t picked up using hatch. But I do want to try it more after reading this article.
Michael #3: Alpha release of the Ruff formatter
vis Sky Kasko
Charlie Marsh announced that an alpha version of a Ruff formatter has been released in Ruff v0.0.289.
The formatter is designed to be a drop-in replacement for Black, but with an excessive focus on performance and direct integration with Ruff.
Sky says: I can't find any benchmarks that have been released yet, but I did some extremely unscientific testing and found the Ruff formatter to be around 5 to 10 times faster than Black when running on already-formatted code or in a small codebase, and 75 times faster when running on a large codebase of unformatted code. (The second outcome probably isn't very important since most people would not often be formatting thousands of lines of completely unformatted code.)
For more info, see the README: https://github.com/astral-sh/ruff/blob/main/crates/ruff_python_formatter/README.md
Brian #4: What is wrong with TOML?
Colm O'Connor
Suggested by Will McGugan
This is a comparison of TOML vs StrictYAML under the use case of “readable story tests”.
TLDR; For smallish things like pyproject.toml, toml is fine. For huge files, something like StrictYAML may be less horrible.
from Brian:
Short answer: Nothing, unless you’re doing crazy things with it.
Re “readable story tests”: WTF? Neither of these are something I’d like to maintain.
Extras
Brian:
Python Testing with pytest, the course
New intro video to explain what the course is about
Using Teachable video
like notes, mini-viewer, and speed controls
Chapter on “Testing Strategy” is next
Michael:
HTMX + Django: Modern Python Web Apps, Hold the JavaScript Course
Coding in Rust? Here's a New IDE by JetBrains
Delightful Machine Learning Apps with Gradio out on Talk Python
Joke: The 5 stages of debugging
9/19/2023 • 29 minutes, 27 seconds
#352 Helicopter Time Comes to Python
Topics covered in this episode:
Heliclockter - Like datetime, but more timezone-aware
Wagtail 5
Git log customization
MiniJinja template engine
Extras
Joke
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Heliclockter - Like datetime, but more timezone-aware
Suggested by Peter Nilsson
The library exposes 3 classes:
datetime_tz, a datetime ensured to be timezone-aware.
datetime_local, a datetime ensured to be timezone-aware in the local timezone.
datetime_utc, a datetime ensured to be timezone-aware in the UTC+0 timezone.
Michael #2: Wagtail 5
Wagtail is the leading open-source Python CMS, based on Django.
Anything you can do in Python or Django, you can do in Wagtail.
Wagtail 5.0 provides even more options for your content creation experience
Dark mode has arrived
SVG support
Enhanced accessibility checker
Delete more safely
Some breaking changes in it because this release removes some of the old code paths that were maintained to give people more time to adapt their code to the new upgrades
Add custom validation logic to your Wagtail projects. You can now attach errors to specific child blocks in StreamField.
Brian #3: Git log customization
Justin Joyce
Just a simple git log --oneline makes the log so much more readable, but don’t stop there.
--graph helps to show different branches
-10 shows the last 10 commits.
And this beauty in .gitconfig makes git lg mostly do what you want most of the time:
[alias]
lg = log --graph -10 --format='%C(yellow)%h%Creset %s %Cgreen(%cr) %C(bold blue)[HTML_REMOVED]%Creset'
Michael #4: MiniJinja template engine
MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2
Comes with integration back into Python via minijinja-py package.
MiniJinja has a stronger sandbox than Jinja2 and might perform ever so slightly better in some situations.
However you should be aware that due to the marshalling that needs to happen in either direction there is a certain amount of loss of information.
Compiles to WebAssembly
Extras
Brian:
The pytest Primary Power course is ready.
To celebrate wrapping up the first course, pytest Primary Power is $49, the bundle is $99.
Bundle: This + next 2 courses + access to repo, discussion forum, Slack, and Discord
Michael:
New HTMX, language course, and data science course coming at Talk Python. Add your name here to get notified.
I’ll be at PyBay 2023 on Oct 8, 2023
Use "friendofspeaker" with for a 20% discount on the regular tickets.
Follow up from docstrings:
From Rhet
John Hagen:
You can certainly omit the type information from the docstring when you are using typehints. This is the way I've seen almost all modern usages of Google style docstrings nowadays. They still have some examples that include the type information because the original standard pre-dated Python 3 type annotations. Here is a simple example:
https://github.com/johnthagen/python-blueprint/blob/main/src/fact/lib.py#L5
This also shows off the next point that you brought up: can I document all of the exceptions that a function could raise. Google docstrings have the "Raises:" block for this, and I find it pretty nice and concise for when this is needed.
Also, PyCharm can be configured to autocomplete and render Google style docstrings
https://www.jetbrains.com/help/pycharm/settings-tools-python-integrated-tools.html
Tools | Python Integrated Tools | Docstrings | Docstring Format: Google
What's nice about this, is that then PyCharm will render the google style docstrings in the Quick Doc function (Ctrl+Q), making the headers bold and larger and lists look nice so it's easy to read.
Joke: Fully optimized my algorithm
9/12/2023 • 22 minutes, 20 seconds
#351 A Python Empire (or MPIRE?)
Topics covered in this episode:
mpire
mopup - the macOS Python.org Updater
Immortal Objects for Python
Common Docstring Formats in Python
Extras
Joke
Watch on YouTube
About the show
Sponsored by Sentry: pythonbytes.fm/sentry
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: mpire
A Python package for easy multiprocessing, but faster than multiprocessing
MPIRE is faster in most scenarios, packs more features, and is generally more user-friendly than the default multiprocessing package.
Tons of features.
Nice intro article with benchmarks.
Brian #2: mopup - the macOS Python.org Updater
Glyph Lefkowitz
On a mac, install Python with the standard Python.org installer.
Then, periodically, update with python3 -m mopup
I just did it and went from Python 3.11.4 to 3.11.5
See also Get Your Mac Python From Python.org for reasons to use python.org over other ways, also from Glyph.
Michael #3: Immortal Objects for Python
Instagram has introduced Immortal Objects – PEP-683 – to Python.
Brian #4: Common Docstring Formats in Python
Scott Robinson
I don’t mean to disrespect Scott, but I’m honestly curious if this is really common.
I like docstrings for the “why” of a function. And prefer type hints for types.
Let me know what you use, at @[email protected]
Extras
Brian:
In search for a working retro Lunar Lander in Python
Michael:
Releases follow up
North Korean hackers behind malicious VMConnect PyPI campaign
Joke: It’s Bingo Time!
9/6/2023 • 35 minutes, 23 seconds
#350 You've Got The Stamina For This Episode
Topics covered in this episode:
Make Each Line Count, Keeping Things Simple in Python
Parsel
A Comprehensive Guide to Python Logging with Structlog
Stamina
Extras
Joke
Watch on YouTube
About the show
Sponsored by Sentry: pythonbytes.fm/sentry
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Make Each Line Count, Keeping Things Simple in Python
Bob Belderbos
Some great tips to help you simplify your Python code to make it more understandable and maintainable.
Michael #2: Parsel
Parsel is a BSD-licensed Python library to extract data from HTML, JSON, and XML documents.
Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors.
It supports:
CSS and XPath expressions for HTML and XML documents
JMESPath expressions for JSON documents
Regular expressions
# Want a RSS feed detail from a website standard HTML?
selector = parsel.Selector(text=html_text)
for link in selector.css('head > link'):
rel = link.xpath('.//@rel').get()
rel_type = link.xpath('.//@type').get()
href = link.xpath('.//@href').get()
Brian #3: A Comprehensive Guide to Python Logging with Structlog
Stanley Ulili
structlog is an awesome logging tool, and already has great documentation.
However, this article is a great starting point, highlighting:
how easy it is to get started using structlog
configuring the default log level
changing the formatting
customizing the time stamp
adding custom fields
adding contextual data
filtering
async
…
Michael #4: Stamina
via Matthias Bach, by Hynek
Production-grade Retries Made Easy
stamina is an opinionated wrapper around the great-but-unopinionated Tenacity package. Its goal is to be as ergonomic as possible, while doing the right thing by default, while minimizing potential for misuse.
General additions on top of Tenacity
Retry only on certain exceptions.
Exponential backoff with jitter between retries.
Limit the number of retries and total time.
Automatic async support.
Preserve type hints of the decorated callable.
Count (Prometheus) and log (structlog) retries with basic metadata, if they’re installed.
Easy global deactivation for testing.
Extras
Brian:
The “pytest fixtures” chapter of the pytest course is available now.
Also, the PYTHONBYTES 20% discount still active for bundle through the end of August.
Michael:
Python 3.12.0 release candidate 1 released
PyCon UK: The conference takes place from the 22nd to the 25th of September in Cardiff, Wales. The schedule is available at 2023.pyconuk.org/schedule/ and tickets are available at 2023.pyconuk.org/tickets/.
PyData Eindhoven 2023, Nov 30 CFP open
PyData Seattle Language Creators Charity Fundraiser: Adele Goldberg - Smalltalk, Guido Van Rossum, Anders Hejlsberg, C#, and James Gosling - Java. September 19, 2023: 12:00 - 4:00 PM, in person only.
Joke:
Librarian
chatgpt-failures
8/29/2023 • 30 minutes, 55 seconds
#349 Djangonauts: Ready for Takeoff!
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Omnivore app
Omnivore is the free, open source, read-it-later app for serious readers.
Distraction free. Privacy focused. Open source. Designed for knowledge workers and lifelong learners.
Save articles, newsletters, and documents and read them later — focused and distraction free.
Add notes and highlights.
Organize your reading list the way you want and sync it across all your devices.
Syncs with popular Personal Knowledge Management systems including Logseq and Obsidian
Wait, what’s Logseq? :)
A privacy-first, open-source platform for knowledge management and collaboration.
Kinda like Notion?
Brian #2: Djangonaut.space
“Where contributors launch”
This is a group mentoring program where individuals will work self-paced in a semi-structured learning environment over the course of three months.
Djangonauts are members of the community who wish to level up their current Django code contributions and potentially take on leadership roles in Django in the future.
Michael #3: Server-side hot reload
Thanks to Alex Riviere for some improvements
Bill Mill suggests websockets and Adam Johnson points he built something like this for Django (sorta) with django-browser-reload
To make it work just:
Include this script in your web projects for dev-time auto reloading of web browser when any change is detected in content.
Works across all web technologies, built out on a FastAPI / Tailwind project.
General workflow looks like:
Edit the source CSS file
Tailwind watcher generates a built CSS file
Built CSS file is included the Python web HTML template
Template appends a hash ID for the state of the CSS file
Changes to the source CSS thus trigger a change in the final ID
New ID means the page contents change and the script does a reload
Even works for static resources if you put a “version” indicator on them:
[HTML_REMOVED]
[HTML_REMOVED]
Brian #4: Python in Excel
Anaconda working with Microsoft to have Python built in to Excel.
“Python in Excel is currently in preview and is subject to change based on feedback. To use this feature, join the Microsoft 365 Insider Program and choose the Beta Channel Insider level.”
from Microsoft Support article: Getting started with Python in Excel
Extras
Brian:
Working on videos for “Ch3 : pytest Fixtures” for the Python Testing with pytest Course Bundle
Adding some drawings and some more bonus videos.
Thanks to everyone who’s signed up already.
I’ve pushed the 20% discount out till the end of August.
I also finally listed it on pythontest.com/courses
Also lots of new interviews for pythonpeople.fm, and I’m expecting at least one new episode of testandcode.com this week.
It’s going to be a busy week.
Michael:
PyCon Sweden CFP is open
Be on Talk Python around Mobile Apps?
Joke:
The Password Game
KennyLog-in.com - secure password generator
8/22/2023 • 31 minutes, 6 seconds
#348 JavaScript in Your Python
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Differentiating between writing down dependencies to use packages and for packages themselves
Brett Cannon
Why can’t we just use pyproject.toml and stop using requirements.txt?
Nope. At least not yet. They’re currently for different things.
pyproject.toml
There’s project.dependencies and project.optional-dependencies.tests that kinda would work for listing dependencies for an app.
But you can’t say pip install -r pyproject.toml. It doesn’t work. And that’s weird.
project is intended for packaged projects.
requirements.txt
for applications and other non-packaged projects
It has specific versions
works great with pip
What then?
Either we stick with requirements.txt
Or we invent some other file, maybe requirements.toml?
Or maybe (Brian’s comment), add something like [application] and application.dependencies and application.optional-dependencies.tests to pyproject.toml
Michael #2: PythonMonkey
PythonMonkey is a Mozilla SpiderMonkey JavaScript engine embedded into the Python VM, using the Python engine to provide the JS host environment.
This product is in an early stage, approximately 80% to MVP as of July 2023. It is under active development by Distributive. External contributions and feedback are welcome and encouraged.
It will enable JavaScript libraries to be used seamlessly in Python code and vice versa — without any significant performance penalties.
Call Python packages like NumPy from within a JavaScript library, or use NPM packages like [crypto-js](https://www.npmjs.com/package/crypto-js) directly from Python.
Executing WebAssembly modules in Python becomes trivial using the WebAssembly API and engine from SpiderMonkey.
More details in Will Pringle’s article.
Brian #3: Quirks of Python package versioning
Seth Larson
Yes, we have SemVer, 1.2.3, and CalVer, 2023.6.1, and suffixes for pre-release, 1.2.3pre1.
But it gets way more fun than that, if you get creative
Here’s a few
v is an optional prefix, like v.1.0
You can include an “Epoch” and separate it from the version with a !, like 20!1.2.3
Local versions with alphanumerics, periods, dashes, underscores, like 1.0.0+ubuntu-1. PyPI rejects those. That’s probably good.
Long versions. There’s no max length for a version number. How about 1.2.3.4000000000000000001?
Pre, post, dev aren’t mutually exclusive: 1.0.0-pre0-post0-dev0
More craziness in article
-
Michael #4: bear-type
Beartype is an open-source PEP-compliant near-real-time pure-Python runtime type-checker emphasizing efficiency, usability, and thrilling puns.
Annotate @beartype-decorated classes and callables with type hints.
Call those callables with valid parameters: Transparent
Call those callables with invalid parameters: Boom
Traceback:
raise exception_cls(
beartype.roar.BeartypeCallHintParamViolation: @beartyped
quote_wiggum() parameter lines=[b'Oh, my God! A horrible plane
crash!', b'Hey, everybody! Get a load of thi...'] violates type hint
list[str], as list item 0 value b'Oh, my God! A horrible plane crash!'
not str.
Extras
Brian:
Python Testing with Pytest Course Bundle: Limited Pre-Release Beta
Use code PYTHONBYTES now through Aug 17 for 20% discount
What’s a pre-release beta? There’s a video. Check out the link.
Error-tolerant pytest discovery in VSCode
Finally! But you gotta turn it on. Also, I gotta talk to them about the proper non-capitalization of pytest.
We’re at RC1 for Python 3.12.0
Hard to believe it’s that time of year again
Michael:
PyPI hires a Safety & Security Engineer, welcome Mike Fiedler
PackagingCon October 26-28
Cloud Builders: Python Conf (born in Ukraine): September 6, 2023 | online
Joke: Learning JavaScript
8/15/2023 • 33 minutes, 14 seconds
#347 The One About Context Mangers
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: async-timeout
An asyncio-compatible timeout context manager.
The context manager is useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for() is not suitable.
Not finished yet timeout can be rescheduled by shift_by() or shift_to() methods
Brian #2: PyPI Project URLs Cheatsheet
Daniel Roy Greenfield
There’s some cool icons available under “Project Links” on pypi.org project pages.
How do you get those? And which ones are available.
Daniel has found out where to look, and built us a cheat sheet. Nice.
Michael #3: httpx-sse
Consume Server-Sent Event (SSE) messages with HTTPX.
SSE are super lightweight, server → client only subscriptions.
Like websockets but less overhead (especially for iot and mobile devices)
httpx-sse provides the connect_sse and aconnect_sse helpers for connecting to an SSE endpoint.
The resulting EventSource object exposes the .iter_sse() and .aiter_sse() methods to iterate over the server-sent events.
Brian #4: Creating a context manager in Python
Trey Hunner
Context managers are those things you use in a with block.
There’s a bunch of cool built in ones.
Building your own is a handy skill to have to clean up your code, and they’re pretty easy, with Trey’s tutorial.
Shown is a great example of temporarily modifying an environmental variable.
Then he gets into what you need to know about as, __enter__, and __exit__.
Extras
Brian:
I think I’ll nix the intro music to Python People. I didn’t know what music to use, so I re-used the music from Test & Code. And I got some very honest feedback that it just doesn’t fit and was better without it. So I’ll rip it out soon.
BTW, next episode to be released is with Bob Belderbos from PyBites. Should be later this week.
Michael:
Facebook and Instagram start blocking news in Canada
Joke:
day 1 and I hate it
8/8/2023 • 36 minutes, 1 second
#346 Have you lost your GIL?
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: A Steering Council notice about PEP 703 (Making the Global Interpreter Lock Optional in CPython)
Thomas Wouters
Suggested by John Hagen
“We intend to accept PEP 703, although we’re still working on the acceptance details.”
Moving forward in 3 stages
short-term, no-GIL experimental build in 3.13 or 3.14
mid-term, declare support for no-GIL version
long-term, no-GIL becomes default and remove any vestiges of the GIL
No commitment and timeframe is nebuous
long-term means 5+ years
Need community support
“We want to be able to change our mind if it turns out, any time before we make no-GIL the default, that it’s just going to be too disruptive for too little gain.”
Michael #2: Google's post-cookie world could turn into DRM for the internet
A new authentication system could let websites block extensions or jailbroken devices.
Google has been trying to implement plans to move beyond cookies for years without denying its partners the means to sell targeted ads.
One recent proposal to guarantee user privacy and security could come at the cost of freedom of functionality.
Comments are somewhat interesting.
More info in a second article.
Vivaldi has a response here.
Brave won’t ship with it.
Brian #3: How ruff changed my Python programming habits
Matthias Kestenholz
“…there’s always a trade off between development speed (waiting on git commit is very boring) and strictness. “
“ruff is so fast that enabling additional rules is practically free in terms of speed...”
ruff has way more rules since last I checked. They are just mostly turned off by default.
The article suggests a bunch to try turning on.
See also
ruff config settings
turn on flake8-bugbear while leaving on defaults with select = ["E", "F", "B"]
lots of rules to choose from
ruff-pre-commit to run these with pre-commit
Michael #4: pathlib api extended to use fsspec backends
via Justin Flannery
Expanding on the capabilities of fsspec, the same GitHub organization also supports another powerful library called universal_pathlib.
universal_pathlib is a python library that aims to extend Python's built-in pathlib.Path api to use a variety of backend filesystems using fsspec.
This seamless replacement allows developers to leverage the familiar and powerful pathlib API on any type of filesystem. upath.Path is a drop-in replacement for pathlib.Path and is an excellent addition to your toolkit.
Joke: Understanding pointers
8/2/2023 • 28 minutes, 9 seconds
#345 Some Big Time Releases
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
The Python People Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Cython 3.0
Long in development, the new major release of the Python-to-C compiler sheds legacy Python support and readies Cython developers for big changes in Python.
Cython 3 cleans up and modernizes Cython.
Pure Python mode allows Python developers to use their existing Python linting and code analysis tools on Cython.
Brian #2: Reading code : An important but seldom-discussed skill
Eric Matthes
A cool walk through of several techniques to read code
Strategies
Ignore function definitions
And in the example, also ignore comments
Simplify repetitive blocks
Examples shows mentally lumping a bunch of print statements into “print message”
Utilize IDE tools, like folding to hide functions your not looking at
Also includes a note about writing readable code.
Notes:
People believe your function and variable names, they should be descriptive, and they should not be deceptive.
Michael #3: Major new version of MicroPython: v1.20.0
via Matt Trentini
>10 months, >1000 mainline commits from >100 contributors
This release of MicroPython introduces a new lightweight package manager called mip.
In the MicroPython runtime, core/built-in types have been compressed by only including in the C-level type struct as many slots for C function pointers as is needed for a given type →
Any third-party C extensions will need to be updated to work with this change.
Massive list of detailed changes.
Brian #4: Advanced Python Tips for Development
Scofield Idehen
There’s 15 in the article, here’s a few
1 & 2. Use List Comprehensions and Generator Expressions.
It’s cool to see them side by side
enumerate() is fun
Embrace zip(). It’s weird, but very useful.
Utilize slots to Reduce Memory Usage
Extras
Brian:
Hear the story behind the quote “I came for the language, but I stayed for the community.” and learn about fountain pens, tea, and a Murderbot, on this week‘s Python People.
Michael:
Search (LLM like) Talk Python: explore-talk-python-to-me.streamlit.app by Aguss
Joke:
You’re full stack now
Seriously, take the HTMX course :)
7/26/2023 • 35 minutes, 52 seconds
#344 AMA: Ask Us Anything
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Main topic: AMA questions from the audience. Use the transcript search to find timestamps if you want to locate a particular one.
Extras
Michael:
Deputy CPython Developer in Residence position accepting applications.
My Make Your Python Web App Fly Around the World with CDNs talk at PWC 2023 is online.
“Joke”: Ode to Python recommended by FelixTheCat
7/18/2023 • 48 minutes, 2 seconds
#343 So Much Pydantic!
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Pydantic v2 released
Pydantic V2 is compatible with Python 3.7 and above.
There is a migration guide.
Check out the bump-pydantic tool to auto upgrade your classes
Brian #2: Two Ways to Turbo-Charge tox
Hynek
Not just tox run-parallel or tox -p or tox --``parallel , but you should know about that also.
The 2 ways
Build one wheel instead of N sdists
Run pytest in parallel
tox builds source distributions, sdists, for each environment before running tests.
that’s not really what we want, especially if we have a test matrix.
It’d be better to build a wheel once, and use that for all the environments.
Add this to your tox.ini and now we get one wheel build
[testenv]
package = wheel
wheel_build_env = .pkg
It will save time. And a lot if you have a lengthy build.
Run pytest in parallel, instead of tox in parallel, with pytest -n auto
Requires the pytest-xdist plugin.
Can slow down tests if your tests are pretty fast anyway.
If you’re using hypothesis, you probably want to try this.
There are some gotchas and workarounds (like getting coverage to work) in the article.
Michael #3: Awesome Pydantic
A curated list of awesome things related to Pydantic! 🌪️
Notable items for me:
ML:
spaCy 🌟(26575) - spaCy is a free open-source library for Natural Language Processing in Python. It features NER, POS tagging, dependency parsing, word vectors and more.
ray 🌟(26496) - Ray provides a simple, universal API for building distributed applications.
jina 🌟(18734) - Jina is geared towards building search systems for any kind of data, including text, images, audio, video and many more. With the modular design & multi-layer abstraction, you can leverage the efficient patterns to build the system by parts, or chaining them into a Flow for an end-to-end experience.
Data
Beanie 🌟(1287) - Beanie - is an Asynchronous Python object-document mapper (ODM) for MongoDB, based on Motor and Pydantic.
Utilities
datamodel-code-generator 🌟(1694) - Pydantic model generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources.
Goodconf 🌟(99) - A thin wrapper over Pydantic's settings management. Allows you to define configuration variables and load them from environment or JSON/YAML file. Also generates initial configuration files and documentation for your defined configuration.
Brian #4: CLI tools hidden in the Python standard library
Simon Willison (and hat tip to Seth Larson)
Simon looked for all of the command line goodies in the standard library.
I knew about python -m http.server to run a server at port 8000 from the local directory, but there’s so much more.
Here are a few
python -m gzip --decompress pypi.db.gz as a gzip utility.
Especially handy on Windows as it doesn’t come with gzip by default
python -m base64 with -d decode, -e encode, and -t encode and decode
python -m asyncio for an asyncio REPL
Tokenize a Python file with python -m tokenize somefile.py
View the AST with python -m ast somefile.py
Pretty print JSON with python -m json.tool
Extras
Brian:
Congrats to Seth Larson, PSFs first Security Developer-in-Residence
Announcing Our New Security Developer in Residence! - PSF announcement
I am the first PSF Security Developer-in-Residence - Seth’s announcement
PythonPeople.fm is live
"The NEW podcast about the people who make the Python community awesome.”
I’m focusing more on the people, and less on the tech.
First episode is with Michael Kennedy
Upcoming episodes in the works with Paul Everitt, Paul McGuire, and Steve Holden.
More people scheduled, many asked, and many more to be asked.
Michael:
MongoDB with Async Python course is out! (talkpython.fm/async-mongodb)
Meta commits to dedicate three engineer-years to implement the removal of the GIL from Python
PyPI has a blog
Joke:
Containers, that’ll fix it
Bonus dad joke: 5 ants rent an apartment. Invite 5 other ants to share the rent. Now there are tenants.
7/11/2023 • 35 minutes, 51 seconds
#342 Don't Believe Those Old Blogging Myths
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Plumbum: Shell Combinators and More
Suggested by Henry Schreiner last week.
(Also, thanks Michael for the awesome search tool on PythonBytes.fm that includes transcripts, so I can find stuff discussed and not just stuff listed in the show notes.)
Plumbum is “ a small yet feature-rich library for shell script-like programs in Python. The motto of the library is “Never write shell scripts again”, and thus it attempts to mimic the shell syntax (shell combinators) where it makes sense, while keeping it all Pythonic and cross-platform.”
Supports
local commands
piping
redirection
working directory changes in a with block. So cool.
lots more fun features
Michael #2: Our plan for Python 3.13
The big difference is that we have now finished the foundational work that we need:
Low impact monitoring (PEP 669) is implemented.
The bytecode compiler is a much better state.
The interpreter generator is working.
Experiments on the register machine are complete.
We have a viable approach to create a low-overhead maintainable machine code generator, based on copy-and-patch.
We plan three parallelizable pieces of work for 3.13:
The tier 2 optimizer
Enabling subinterpreters from Python code (PEP 554).
Memory management
Details on superblocks
Brian #3: Some blogging myths
Julia Evans
<from Brian: I’m not sure if I’m including this to convince all of you to blog more, or to convince myself. Hopefully both happens.>
myths (more info of each in the blog post):
you need to be original
you need to be an expert
posts need to be 100% correct
writing boring posts is bad
you need to explain every concept
page views matter
more material is always better
everyone should blog
I’d add
Write posts to help yourself remember something.
Write posts to help future prospective employers know what topics you care about.
You know when you find a post that is outdated and now wrong, and the code doesn’t work, but the topic is interesting to you. Go ahead and try to write a better post with code that works.
Michael #4: Jupyter AI
A generative AI extension for JupyterLab
An %%ai magic that turns the Jupyter notebook into a reproducible generative AI playground. This works anywhere the IPython kernel runs (JupyterLab, Jupyter Notebook, Google Colab, VSCode, etc.).
A native chat UI in JupyterLab that enables you to work with generative AI as a conversational assistant.
Support for a wide range of generative model providers and models (AI21, Anthropic, Cohere, Hugging Face, OpenAI, SageMaker, etc.).
Official project from Jupyter
Provides code insights
Debug failing code
Provides a general interface for interaction and experimentation with currently available LLMs
Lets you collaborate with peers and an Al in JupyterLab
Lets you ask questions about local files
Video presentation: David Qiu - Jupyter AI — Bringing Generative AI to Jupyter | PyData Seattle 2023
Extras
Brian:
Textual has some fun releases recently
Textualize youtube channel with 3 tutorials so far
trogon to turn Click based command line apps into TUIs
video example of it working with sqlite-utils.
Python in VSCode June Release includes revamped test discovery and execution.
You have to turn it on though, as the changes are experimental:
"python.experiments.optInto": [
"pythonTestAdapter",
]
I just turned it on, so I haven’t formed an opinion yet.
Michael:
Michael’s take on the MacBook Air 15” (black one)
Joke: Phishing
6/26/2023 • 41 minutes, 47 seconds
#341 Shhh - For Secrets and Shells
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Pydantic roadmap
via Mario Munoz
Back in February [Samuel] [announced](https://pydantic.dev/announcement/) Pydantic Inc., but I didn't explain what services we were building.
The problem is that even with Pydantic in your corner, working with data when it leaves Python often still sucks.
We want to build a data platform to make working with data quick, easy, and enjoyable — where developer experience is our north star.
There are five key components to the Pydantic Data Platform that we're thinking of building.
Python Analytics/Observability — a logging and metrics platform with tight Python and Pydantic integration, designed to make the data flowing through your application more readily usable for both engineering and business analytics. More info...
Data Gateway for object stores — Add validation, transformation and cataloguing in front of object stores like S3, with a schema defined in Pydantic models then validated by our Rust service. More info...
Data Gateway for data warehouses — the same service as above, but integrated with your existing data warehouse. More info...
Schema Catalog — for many, Pydantic already holds the highest fidelity representation of their data schemas. Our Schema Catalog will take this to the next level, serving as an organization-wide single source of truth for those schemas, tracking their changes, and integrating with our other tools and your wider platform. More info...
Dashboards and UI powered by Pydantic models — a managed platform to deploy and control dashboards, auxiliary apps and internal tools where everything from UI components (like forms and tables) to database schema would be defined in Python using Pydantic models. More info...
Tell them what you think with their survey
Brian #2: The Right Way to Run Shell Commands From Python
Martin Heinz
Should have a tagline of “especially if you’re on Mac or Linux”.
Includes discussion of
Python native tools - recommended
a few os module functions - but otherwise avoid relying too much on os.
subprocess.run() - stick with run() if you can.
sh third party package - should be second choice if on Linux or Mac
Michael #3: US: Yep, We're Buying Your Data, Including Your Embarrassing Secrets
Digital information can be purchased from commercial data brokers and 'deanonymized' to ID the person it's tied to, including US citizens, the Office of the Director of National Intelligence says.
The Office of the Director of National Intelligence (ODNI) on Friday declassified(Opens in a new window) a report from January 2022 that outlines the US government’s approach to using Commercially Available Information (CAI), which can come from data brokers working in the internet ad and analytics industries.
The purchased information includes details from users' smartphones and social media accounts.
To all the “please disable your ad blockers” companies out there
1) It’s not just about supporting your website
2) Ad blockers are not just avoiding ads.
3) It’s not even necessary (our ads are not blocked on the podcast or the website)
Consider browser != Chrome and/or nextdns.io for your whole network
Brian #4: Pro-Tip – pytest fixtures are magic!
Frank Wiles
“The magic of pytest fixtures is how they are injected into your tests for you to use and their composability. When done well, writing tests is considerably easier and actually fun.”
Setup code is often the biggest headache of test writing. pytest fixtures help solve the setup problem.
Fixtures
are used by just including them in a tests parameter list
can build on top of each other
can be used in any test in the project, if you put it in a central conftest.py
can return all kinds of things: static data, instantiated objects, callables to make other things,
Frank includes an interesting way to organize fixtures such that they are defined in local test directories but usable across a project, under “Organizing Your Fixtures”.
Plugins with fixtures: A shoutout to pytest-django and a Revsys plugin called django-test-plus.
Built-in fixtures. See also tmp_path.
autouse
One bit of incorrect info: autouse doesn’t work like that. The value of global_thing cannot be grabbed unless you list it in the parameter list. It will run before every function (since it’s scope=``"``function``" by default), but you gotta list it to get the value.
To be fair, it’s really hard to come up with good autouse examples. Partly because there are so few good reasons to use autouse.
Extras
Brian:
Porting Python projects to Rust
International Obfuscated Python Code Competition
Michael:
Remember the AMA (submit your question). “Scheduled” on July 11th at 11am.
Joke: Marked as duplicate
6/20/2023 • 35 minutes, 8 seconds
#340 Snorkel not included
Watch on YouTube
About the show
Sponsored by InfluxDB from Influxdata.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Ask me anything episode: Submit your question(s) for our upcoming AMA episode: form here. Thank you!
Brian #1: PythonGUIS
Martin Fitzpatrick
A site with a collection of resources, guides, books, comparisons, etc, around GUIs in Python.
Martin recommends starting with PyQT6
However, there are tutorials covering
PyQT6
PySide6
PyQT5
TkInter
PySide
even Kivy
Michael #2: JupyterLab 4.0 is Here
The next major release of our full-featured development environment
You can upgrade by running pip install --upgrade jupyterlab or conda install -c conda-forge jupyterlab.
JupyterLab is now faster, thanks to improvements such as CSS rules optimization, CodeMirror 6, MathJax 3, and notebook windowing. JupyterLab 3 was when working with large notebooks.
There are additional performance improvements available via opt-in settings:
Faster tab-switching on Chromium browsers:
“Settings” → “JupyterLab Shell” → switch “Hidden mode” to “contentVisibility”
Better performance with long notebooks:
“Settings” → “Notebook” → switch “Windowing mode” to “full”
An upgraded text editor.
Better real time collaboration.
Bug fixes. More than 100 bugs have been addressed and resolved, enhancing JupyterLab’s stability and performance.
Brian #3: Proposing a struct syntax for Python
Brett Cannon
This would be a cool syntax for a data only type: struct Point(x: int, y: int)
No positional only parameters
No inheritance
No methods
Instances would be immutable, so p = Point(1, 2) would create an object that could be used as a key.
A data only focused set of types.
Michael #4: Python 3.13 Removes 20 Stdlib Modules
via PyCoders
From PEP 594 – Removing dead batteries from the standard library we’re saying goodbye to
aifc, audioop, cgi, cgitb, chunk, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu, xdrlib
As well as the 2to3 program and lib2to3 module in Python.
Python 3.12 final release is scheduled in 4 months (October 2023) and Python 3.13 final release is scheduled in 1 year and 4 months (October 2024).
Extras
Brian:
Affirming your PSF Membership voting status
You have until June 15 to affirm your voting rights in the upcoming Board Election, if you care about such things.
Michael:
5 Career Tips for Budding Python Developers video
PyCon US 2023 videos are up
Python 3.11.4, 3.10.12, 3.9.17, 3.8.17, 3.7.17, and 3.12.0 beta 2 are now available
Joke: Snorkel not included
6/13/2023 • 31 minutes, 9 seconds
#339 Actual Technical People
Watch on YouTube
About the show
Sponsored by InfluxDB from Influxdata.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: pystack
PyStack is a tool that uses forbidden magic to let you inspect the stack frames of a running Python process or a Python core dump, helping you quickly and easily learn what it's doing.
PyStack has the following amazing features:
💻 Works with both running processes and core dump files.
🧵 Shows if each thread currently holds the Python GIL, is waiting to acquire it, or is currently dropping it.
🗑️ Shows if a thread is running a garbage collection cycle.
🐍 Optionally shows native function calls, as well as Python ones. In this mode, PyStack prints the native stack trace (C/C++/Rust function calls), except that the calls to Python callables are replaced with frames showing the Python code being executed, instead of showing the internal C code the interpreter used to make the call.
🔍 Automatically demangles symbols shown in the native stack.
📈 Includes calls to inlined functions in the native stack whenever enough debug information is available.
🔍 Optionally shows the values of local variables and function arguments in Python stack frames.
🔒 Safe to use on running processes. PyStack does not modify any memory or execute any code in a process that is running. It simply attaches just long enough to read some of the process's memory.
⚡ Optionally, it can perform a Python stack analysis without pausing the process at all. This minimizes impact to the debugged process, at the cost of potentially failing due to data races.
🚀 Super fast! It can analyze core files 10x faster than general-purpose tools like GDB.
🎯 Even works with aggressively optimized Python interpreter binaries.
🔍 Even works with Python interpreters' binaries that do not have symbols or debug information (Python stack only).
💥 Tolerates memory corruption well. Even if the process crashed due to memory corruption, PyStack can usually reconstruct the stack.
💼 Self-contained: it does not depend on external tools or programs other than the Python interpreter used to run PyStack itself.
Brian #2: Securing PyPI accounts via Two-Factor Authentication
Donald Stufft
“… every account that maintains any project or organization on PyPI will be required to enable 2FA on their account by the end of 2023.”
“One of the key security promises that PyPI makes is that when you're downloading something, that only the people associated with that project are going to be able to upload, delete, or otherwise modify a project. That when you look at that project and see that it is owned by someone that you trust, that you can be assured that nobody else is making changes to that package on PyPI.”
If you maintain a package on PyPI to a point where you are uploading to PyPI or plan to soon, enable 2FA on you account.
May as well do it sooner than later. But officially, you have the rest of the year.
This has already been a requirement for “critical projects” since last summer. (top 1% of downloads, about 3,500 projects.) See episode 293.
Now it’s going to be for everyone.
Michael #3: Propan - a declarative Python MQ framework
Propan is a powerful and easy-to-use Python framework for building asynchronous web services that interact with any MQ Broker.
It's following by fastapi, simplify Message Brokers around code writing and provides a helpful development toolkit, which existed only in HTTP-frameworks world until now.
It is a modern, high-level framework on top of popular specific Python brokers libraries, based on pydantic and fastapi, pytest concepts.
The key features are
Simple: Designed to be easy to use and learn.
Intuitive: Great editor support. Autocompletion everywhere.
Dependencies management: Minimization of code duplication. Access to dependencies at any level of the call stack.
Integrations: Propan is fully compatible with any HTTP framework you want
MQ independent: Single interface to popular MQ:
Redis (based on redis-py)
RabbitMQ (based on aio-pika)
Kafka (based on aiokafka)
SQS (based on aiobotocore)
Nats (based on nats-py)
RPC: The framework supports RPC requests over MQ, which will allow performing long operations on remote services asynchronously.
Great to develop: CLI tool provides great development experience:
framework-independent way to manage the project environment
application code hot reload
robust application templates
Testability: Propan allows you to test your app without external dependencies: you do not have to set up a Message Broker, you can use a virtual one!
Brian #4: Makefile tricks for Python projects
Ricardo Ander-Egg
A pretty short basic starter template Makefile for Python projects with some cool snippets.
Some default settings to have make behave sanely
exit on error, warn about undefined variables, disable built-in rules
set up working directory correctly if called from a different dir
A $(py) definition that picks up the virtual environment if it’s there.
Also $(pip) from the virtual env.
Default goal and help message
cool trick so that make with no arguments just prints the help
And also picks up target comments as help text for the target. Neat.
Injecting paths into PYTHONPATH, and an example on how that works if you need it.
A .venv target
create a virtual environment, update setuptools, wheel, build, and install requirments
Extras
Michael:
PyCon Portugal CFP
DjangoCon 2024
Apple Vision Pro
Duet App
Joke: Actual technical people
6/7/2023 • 30 minutes, 43 seconds
#338 Scripting iOS with Python
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Special guest: GUEST_PROFILE
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: The Basics of Python Packaging in Early 2023
Jay Qi
Good description of a minimal-ish pyproject.toml file, which includes a build backend and project metadata.
That’s all you need for a Python-only project.
Discussion of how to choose a build backend. Mostly it’s baed on extra features you might want, like hatchling’s include/exclude features for source distributions.
Some discussion of frontend choices.
Nice discussion of non-Python-only builds. Specifically, if you need to compile C or C++ extensions, you can use scikit-build-core, or meson-python, or setuptools.
Related: "Sharing is Caring - Sharing pytest Fixtures" by Brian Okken (PyCascades 2023)
My PyCascades 2023 on packaging pytest plugins is up on YouTube
Michael #2: vecs
via Oli
Python collection-like interface to storing and searching vectors in postgres.
Vector search is a key component in building AI chatbots, and semantic document search.
If you're familiar with the space, it's effectively Pinecone built on free OSS
It's under the Supabase github org but it's fully open source, and compatible with any pgvector vendor, e.g. RDS, or locally in docker
If you’re on macOS and need Postgres, Postgres App is a good option.
Brian #3: Introducing Grasshopper - An Open Source Python Library for Load Testing
Jacob Fiola
“Grasshopper is a library for automated load testing, written in Python.”
Open source project from Alteryx,
On GitHub and PyPI under the name locust-grasshopper
Built on Locust.
Adds
Tag-based suites for trend analysis and evaluating changes.
Custom trends. Useful for actions that span multiple http calls, and you want to see timing trends for the whole action.
Checks. Checks validate boolean conditions in the test.
Custom tagging for all metrics
Send data to time series db & dashboards.
Thresholds.
Reporting results to other locations.
Some reusable base classes that take care of the majority of the boilerplate that tests often contain
Readme has a very thorough introduction including configuration and samples.
Michael #4: memocast
by Daniel Engvall
A small iOS app for e.g. iPhone that allow you to add links heard in podcasts into reminders.
Good example of how to use Pythonista to build python scripts for iOS
Pythonista just made an update (2 weeks ago) so that'd use Python 3.10 on the iOS which makes it even more interesting.
Extras
Brian:
Help test Python 3.12 beta!
Python Language Summit write-ups available
PyPI was subpoenaed
Michael:
You Can Ignore This Post
Joke: Careful or you might end up summoning a demon.
5/30/2023 • 30 minutes, 20 seconds
#337 Backtracking For a Package
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Special guest: GUEST_PROFILE
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Ruff PyCharm plugin
via John Hagen
Ruff PyCharm plugin has great integration, it will highlight Ruff lint errors in the IDE as you type and you can even apply Alt+Enter (⌥⏎ on Mac) quick fixes through the IDE.
Ruff will automatically fix the fixable issues.
John also added additional PyCharm-specific instructions for black/Ruff
Brian #2: Writing Python like it's Rust
Kobzol
Rust lessons guiding use of types and type hints in Python
Add type hints tun function signatures
Use dataclasses instead of tuples or dictionaries to increase clarity and type safety
Union types to clarify | typing
Michael #3: Pip 23.1 Released - Massive improvement to backtracking
Pip 23.1 was released last month
Highlight the significant improvement in backtracking that is part of the requirement resolver process in Pip. This process involves Pip finding a set of packages that meet your requirements and whose requirements themselves don't conflict.
Prior to Pip 20.3, the default process for Pip would allow conflicting requirements to install if they were transitive dependencies where the last one specified would be the one installed.
Once the new resolver was turned on by default it immediately hit problems where backtracking would get stuck for a long time.
Pip separates out the resolution logic into a library called resolvelib. It had been discovered that there was a logical error under certain circumstances, and also there was a known better backtracking technique it could employ called backjumping.
Both of these were recently fixed and implemented in resolvelib, which were then vendored in to Pip 23.1.
Brian #4: Markdown Code Runner
markdown-code-runner is a Python package that automatically executes code blocks within a Markdown file, including hidden code blocks, and updates the output in-place.
Works with Python & Bash
see also cog
Extras
Brian:
Use code SPRING2023 to get 50% off “Python Testing with pytest, 2nd edition” before June 1.
Michael:
Python 3.12.0a7 is out
python3 -m venv --upgrade-deps venv (via John Hagen)
Talk submissions are now open for both remote and in-person talks at the 2023 PyConZA? The conference will be held on 5 and 6 October 2023 in Durban, South Africa. South Africa is GMT+2, so the times are convenient for Africa, Europe and much of Asia, although probably less so for the rest of the world. All details are on za.pycon.org - via Kim van Wik
Trail discovery/riding apps
onX offroad
Gaia
Picture of Michael on one of these trails
Joke: User Inyerface
5/23/2023 • 32 minutes, 18 seconds
#336 We found one of your batteries
Watch on YouTube
About the show
Sponsored by InfluxDB from Influxdata.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Python's Missing Batteries: Essential Libraries You're Missing Out On
Martin Heinz
Fun collection of a bunch of libraries you may not know about (or forgot about), with code examples.
Utilities
boltons : iterate through json and dates, quickly grab data out of nested structures, and convert nested data with jsonutils, timeutils, and iterutils
sh : conveniently call shell funcitons
Data Validation
validators : validate email addresses, credit cars, IP addresses, and more.
the fuzz : fuzzy string comparisons
Debugging
stackprinter : nice stack traces with exception messages higlighted
Testing
freezegun : stop time, change dates, …
dirty_equals : comparing things that are kinda equal
CLI
tqdm : add a progress bar to command line apps
Michael #2: awesome-polars
A curated list of Polars talks, tools, examples & articles.
Mostly articles and tutorials however.
Brian #3: Running Headless Selenium in Python (2023)
Siddiqi
First off, if you are doing automated testing with Selenium, I hope you already know about headless. It’s awesome and speeds up testing.
Next, there’s changes to how you code headless, as of Selenium 4.8.0 (Jan. 2023).
Old:
options.headless` `**=**` `True
New:
options.add_argument('--headless=new') for Chrome
options.add_argument('--headless') for Firefox
Reasons: Read Headless is Going Away! post on Selenium blog.
Subtitle: “Now that we got your attention, headless is not actually going away, just the convenience method to set it in Selenium”
Michael #4: Gracy
Gracy helps you handle failures, logging, retries, throttling, and tracking for all your HTTP interactions.
Has support for
Parsing per status code
Throttling
Retries
Custom validation
Record/replay for testing
A bit non-pythonic but perhaps inspriation for some out there
Extras
Michael:
Mobile apps are finally out
Take the git course for free for a limited time.
Michael's blog post announcing the apps
Joke: It’s practice
5/16/2023 • 28 minutes, 28 seconds
#335 Should you get your mojo on?
Watch on YouTube
About the show
Sponsored by InfluxDB from Influxdata.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Introducing 'Trusted Publishers’
PyPI package maintainers can adopt a new, more secure publishing method that does not require long-lived passwords or API tokens to be shared with external systems.
Our term for using the OpenID Connect (OIDC) standard to exchange short-lived identity tokens between a trusted third-party service and PyPI.
Instead, PyPI maintainers can configure PyPI to trust an identity provided by a given OpenID Connect Identity Provider (IdP).
These API tokens
never need to be stored or shared
rotate automatically by expiring quickly
provide a verifiable link between a published package and its source
Additional security hardening is available
Brian #2: Mojo : a new programming language for all AI developers.
Mojo may be the biggest programming language advance in decades - fast.ai blog
Suggested by many listeners
“Mojo combines the usability of Python with the performance of C, unlocking unparalleled programmability of AI hardware and extensibility of AI models.”
A programming language compatible with Python, with performance similar to C++/Rust.
“Mojo is designed to become a superset of Python over time by preserving Python’s dynamic features while adding new primitives for systems programming.” - emphasis from Brian
It’s not there yet, but still super cool
Built on a MLIR, not LLVM
“How compatible is Mojo with Python really?
Mojo already supports many core features of Python including async/await, error handling, variadics, etc, but… it is still very early and missing many features - so today it isn’t very compatible. Mojo doesn’t even support classes yet!”
Michael #3: django-prose
Wonderful rich-text editing for your Django project.
Rendering rich-text in templates
Small rich-text content (as model fields)
Django Prose is using Bleach to only allow certain tags and attributes
See the website for a screenshot of it in action
Brian #4: pylyzer is a static code analyzer / language server for Python, written in Rust.
Shunsuke Shibayama
Suggested by Owen
Features
fast
detailed analysis
type checking
plus things like out-of-bounds accesses to lists, and non-existent key references to dicts
more readable reports
and a VS Code extension
pylyzer vs ruff
“Ruff, like pylyzer, is a static code analysis tool for Python written in Rust, but Ruff is a linter and pylyzer is a type checker & language server. pylyzer does not perform linting, and Ruff does not perform type checking.”
Some limitations and incomplete “todo list”. See README for more details.
Joke: Escape Room
5/11/2023 • 25 minutes, 37 seconds
#334 Packaging Organizations
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: rye - Python workflow tool
Armin Ronacher
Rust built tool, currently only for Linux and MacOS
Project workflow commands, like
init - new project
add - add a dependency (including optional)
remove - remove a dependency
build - build wheel
lock - update lock file
virtualenv commands
add —dev - install in environment
sync - install/update dependencies in env based on pyprojec.toml
run - run command within environment
Install Python
fetch - Fetches a Python interpreter for the local machine
Register existing Python
toolchain Helper utility to manage Python toolchains
Kinda like pipx
install - Installs a package as global tool
uninstall - Uninstalls a global tool
I didn’t see that it added anything to my PATH, so this addition made it work:
Bonus
Everything lives under ~/.rye
So it’s easy to stop using, and doesn’t muck up
see also
Simon Willison’s A few notes on Rye
Python Bytes #332, where we talked about huak
Michael #2: PyPI Organizations
The first step in our plan to build financial support and long-term sustainability of the Python Packaging Index (PyPI)
Small fee for organizations rather than individual users
Like Github orgs
Brian #3: 5 tips to learn any new Python library faster
Bob Belderbos
The tiips
RTFM - at lest the getting started docs
Install it
Explore the library - play. Bob recommends Jupyter notebook for this.
Apply it to a real world problem - deliberate practice
Build something with it
(bonus) Teach it - blog, TIL, video tutorial, etc.
Michael #4: Python gets down to (the) Metal
Extras
Brian:
frogmouth - Markdown viewer / browser for your terminal, built with Textual.
Michael:
Was going to talk about Serenade, but seems to have gone silent.
Packaging follow up discussion.
Joke: It’s the progress that counts
5/5/2023 • 32 minutes, 22 seconds
#333 Live From PyCon
Watch on YouTube
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Introducing Microsoft Security Copilot
Security Copilot combines this advanced large language model (LLM) with a security-specific model from Microsoft.
When Security Copilot receives a prompt from a security professional, it uses the full power of the security-specific model to deploy skills and queries that maximize the value of the latest large language model capabilities.
Your data and stays within your control. It is not used to train the foundation AI models, and in fact, it is protected by the most comprehensive enterprise compliance and security controls.
Brian #2: PEP 695 – Type Parameter Syntax
“This PEP specifies an improved syntax for specifying type parameters within a generic class, function, or type alias. It also introduces a new statement for declaring type aliases.”
To get a feel for this, jump to the examples
One example
Here is an example of a generic function today.
from typing import TypeVar
_T = TypeVar("_T")
def func(a: _T, b: _T) -> _T:
...
- And the new syntax.
def func[T](a: T, b: T) -> T:
...
Michael #3: Auto-GPT
An experimental open-source attempt to make GPT-4 fully autonomous.
This program, driven by GPT-4, chains together LLM "thoughts", to autonomously achieve whatever goal you set.
Features
🌐 Internet access for searches and information gathering
💾 Long-term and short-term memory management
🧠 GPT-4 instances for text generation
🔗 Access to popular websites and platforms
🗃️ File storage and summarization with GPT-3.5
Brian #4: Astral : Ruff is now a company
Charlie Marsh announces Astral, starting off with a healthy $4m in seed money. Not a bad start
Astral will continue building high-performance developer tools for the Python ecosystem — to keep building Ruff, and to build more Ruff-like things.
“to make the Python ecosystem more productive by building high-performance developer tools.”
Undoubtedly Rust-ifying more of the Python tool chain.
Related:
In a discussion at PyCon, someone asked me if Ruff was a replacement for Black.
My answer, “not really, more of a flake8 replacement and a few other tools, but a partial overlap with Black.
Real answer is at the FAQ
Is Ruff compatible with Black?
Yes. Ruff is compatible with Black out-of-the-box, as long as the line-length setting is consistent between the two.
As a project, Ruff is designed to be used alongside Black and, as such, will defer implementing stylistic lint rules that are obviated by autoformatting.”
Extras
Brian:
Registration open for SciPy 2023
Michael:
Android Mobile App is out. Please give us feedback
Joke: Releasing to prod
4/22/2023 • 22 minutes, 38 seconds
#332 A Python, a Slurpee, and Some Chaos
Watch on YouTube
About the show
Sponsored by InfluxDB from Influxdata.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: huak - A Python package manager written in Rust. Inspired by Cargo
Suggested by Owen
Tons of workflows
activate - activate a virtual environment
add add a dependency to a project
pip install it into your virtual environment, and add it to the dependency list in pyproject.toml
test - run pytest
update update dependencies
lint - run ruff, installing it first if necessary
fix - autofix fixable lint conflicts
build - build wheel in isolated virtual environment using hatchling
Honestly
I was considering building my own workflow tool, but this is darned close to what I want.
Even though it’s still “in an experimental state”.
There are rough edges (ruff edges, get it), but still, way cool.
I just don’t know how to pronounce it. Is it like “walk”, or more like “whack”?
Michael #2: PSF expresses concerns about a proposed EU law that may make it impossible to continue providing Python and PyPI to the European public
After reviewing the proposed Cyber Resilience Act and Product Liability Act, the PSF has found issues that put the mission of our organization and the health of the open-source software community at risk.
As currently written, the authors of open-source components might bear legal and financial responsibility for the way their components are applied in someone else’s commercial product.
The risk of huge potential costs would make it impossible in practice for us to continue to provide Python and PyPI to the European public.
Brian #3: ChaosToolkit
Suggested by the maintainer, Sylvain Hellegouarch
Declare and store your Chaos Engineering experiments as JSON/YAML files so you can collaborate and orchestrate them as any other piece of code.
Extensible through an Open API
Can be automated in CI/CD pipeline
Michael #4: PEP 711 – PyBI: a standard format for distributing Python Binaries
“Like wheels, but instead of a pre-built python package, it’s a pre-built python interpreter”
Joke: It’s the effort that counts
4/18/2023 • 36 minutes, 56 seconds
#331 Python From the Future
Watch on YouTube
About the show
Sponsored by InfluxDB from Influxdata.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: makeapp
via Felix Ingram
Simplifies Python application rollout and publishing.
Link to its mention on Talk Python.
Simplifies Python application rollout and publishing:
Make a skeleton for your new application with one console command
Automatically create a VCS repository for your application.
Automatically check whether the chosen application name is not already in use.
Customize new application layouts with skeleton templates.
Put some skeleton default settings into a configuration file not to mess with command line switches anymore.
Easily add entries to your changelog.
Publish your application to remotes (VCS, PyPI) with single command.
Brian #2: Looking forward to Python 3.12
We’re on 3.12.0a7 now, the last alpha, final is scheduled for October
schedule
So far, in 3.12.0a7
What’s new in Python 3.12 page has some examples of the Improved Error Messages
Recent addition, PEP 684 - A Per-Interpreter GIL was approved recently
“… sufficient isolation would facilitate true multi-core parallelism …” seems like a good thing.
But also, “… this is an advanced feature meant for a narrow set of users of the C-API. “, so not really sure how this will affect us.
Still, seems cool.
Michael #3: Python 3.11.3 is out
Fixes a HIGH level CVE in OpenSSL (so patch it)
Lots of changes in Core and Builtins
Brian #4: How to Make a Great Conference Talk
Sebastian Witowski
Lots of great advice for tech conf talks.
Don’t skip the last half of this, getting your talk accepted is really when the work starts.
Good sections to make sure you don’t miss
Live demos
“First of all - do you really need a demo? …”
Rehearsing
Don’t skip this. Do this. A lot. Out loud. With a timer. While standing.
Memorize the first few minutes, and the last few.
Know how you’re going to open and close.
Night before
get enough sleep
Day of
eat well. Don’t drink too much liquids. Be comfortable.
Sebastian was honest in saying this stuff works for him, but do what works for you.
From Brian:
I deviate from Sebastian in quite a few places, but still don’t disagree with his advice.
I can’t give a talk without slides, as I use them for prompts to know what I’m talking about next.
My talks usually have a lot of code snippets. Obviously, that would be difficult without slides.
I write my talk and my slides in Markdown. Sebastian writes in something else, then builds slides as visual aids. That’s cool.
Do what works for you.
Bonus tool from the article:
demo-magic - If I’m ever tempted to live code again, I think I’ll try this instead.
Extras
Michael:
NOW the CDN course is out.
Django 4.2 released.
Joke:
Using A.I. for Efficiency
4/12/2023 • 35 minutes, 57 seconds
#330 Your data, validated 5x-50x faster, coming soon
Watch on YouTube
About the show
Sponsored by Influxdb
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Pydantic V2 Pre Release
Terrence Dorsey & Samuel Colvin
Alpha release available to everyone: pip install --pre -U "pydantic>=2.0a1"
Headlines:
pydantic-core - all validation logic rewritten in Rust and moved to separate package, pytest-core
5-50x faster
separation will aid safety and maintainability
Lots ready for experimentation
BaseModel, Dataclasses, Serialization, …
Much still under construction
Docs, BaseSettings→ pydantic-settings, …
Michael #2: microdot The impossibly small web framework for Python and MicroPython
Microdot is a minimalistic Python web framework inspired by Flask, and designed to run on systems with limited resources such as microcontrollers.
It runs on standard Python and on MicroPython.
Support for async, websockets, tls, even ASGI servers.
Less mem usage by a big margin.
Brian #3: GitHub Actions Tools: watchgha, build and inspect, and pytest annotate failures
watchgha
Ned Batchelder
Watch GH Actions progress on the command line
build-and-inspect-python-package
Hynek
Test the build of wheels, check contents, lint README
print sdist contents, wheel contents, and metadata
pytest-github-actions-annotate-failures
utgwkk
Nice traceback annotations for pytest
Michael #4: PEP 709 – Inlined comprehensions
by Carl Meyer
Comprehensions are currently compiled as nested functions, which provides isolation of the comprehension’s iteration variable, but is inefficient at runtime.
This PEP proposes to inline list, dictionary, and set comprehensions into the code where they are defined, and provide the expected isolation by pushing/popping clashing locals on the stack.
This change makes comprehensions much faster: up to 2x faster for a microbenchmark of a comprehension alone.
Extras
Michael:
Python Web Apps that Fly with CDNs Course
Joke: Can’t watch movies
4/6/2023 • 34 minutes, 25 seconds
#329 Creating very old Python code
Watch on YouTube
About the show
Sponsored by Microsoft for Startups Founders Hub.
Michael #1: Prefix-cache
via Brendan Hannigan
You can set an environment variable or use it as a command line argument and then instead of creating tons of __pycache__ folders to store your *.pyc files right next to the source code, it puts them in some specified folder.
Introduced in python 3.8.
Brian #2: NiceGUI
Suggested by several listeners
Browser based GUI
“NiceGUI is an easy-to-use, Python-based UI framework, which shows up in your web browser. You can create buttons, dialogs, Markdown, 3D scenes, plots and much more.
It is great for micro web apps, dashboards, robotics projects, smart home solutions and similar use cases. You can also use it in development, for example when tweaking/configuring a machine learning algorithm or tuning motor controllers.” - from the README
Michael #3: flask-ngrok
A simple way to demo Flask apps from your machine.
Makes your Flask apps running on localhost available over the internet via ngrok.
Great for testing API consumers too.
app = Flask(__name__)
run_with_ngrok(app) # Start ngrok when app is run
# Endpoints ...
if __name__ == '__main__':
app.run()
Brian #4: No-async async with Python
Will McGugan
Allowing async while not requiring async
Await me (maybe)
borrowed from Simon Willison’s The “await me maybe” pattern for Python asyncio
Optionally awaitable
Providing API methods that can be called by both async and non-async code.
The called method really is async, but if a caller doesn’t want to know when the code is done, it can ignore the return value and not await.
MK: I had to solve a similar problem in fastapi-chameleon
MK: Syncify async functions.
Extras:
Brian:
PyPI has a blog
Docker no longer sunsetting free team plan
Jokes:
Long-lived software
Mysteries make life more interesting
last paragraph, discussing the cov fixture of pytest-cov
3/30/2023 • 28 minutes, 52 seconds
#328 We are going to need some context here
Watch on YouTube
About the show
Sponsored by Microsoft for Startups Founders Hub.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: zipapp
Part of standard library since 3.5
Yet another thing I learned recently from Brett Cannon
“This module provides tools to manage the creation of zip files containing Python code, which can be executed directly by the Python interpreter. The module provides both a Command-Line Interface and a Python API.”
Including: Creating Standalone Applications with zipapp
Michael #2: Reverse engineering the Apple News app with #python and #nerd power
As we navigate the digital world, we often come across articles we don't have time to read but still want to save for later.
One way to accomplish this is by using the Read Later feature in Apple News.
But what if you want to access those articles outside the Apple News app, such as on a different device or with someone who doesn't use Apple News?
Or what if you want to automatically post links to those articles on your blog? That's where the nerd powers come in.
The linked article shows how to use Python to solve your own problem
Leading to Rhet Turnbull’s CLI: apple-news-to-sqlite
Brian #3: What is a context manager?
Trey Hunner
Also look at all the cool goodies in contextlib from standard library
@contextmanager
closing
suppress
redirect_stdout, redirect_stderr
chdir
Michael #4: nox-poetry: Use Poetry inside Nox sessions
via 2 people: John Hagen and Marc Prewitt
This package provides a drop-in replacement for the nox.session decorator, and for the nox.Session object passed to user-defined session functions.
Comes from Claudio Jolowicz's hypermodern python cookiecutter
Covered this on Talk Python: talkpython.fm/episodes/show/362/hypermodern-python-projects
This session performs the following steps:
Build a wheel from the local package.
Install the wheel as well as the pytest package.
Invoke pytest to run the test suite against the installation.
Consider what would happen in this session if we had imported @session from nox instead of nox_poetry:
Package dependencies would only be constrained by the wheel metadata, not by the lock file. In other words, their versions would not be pinned.
The pytest dependency would not be constrained at all.
Poetry would be installed as a build backend every time.
Extras
Brian:
Sharing is Caring: Sharing pytest fixtures talk availabe at about 2:40:58 on Day 2 video of PyCascades 2023.
Also full Day 1 and Day 2
Michael:
Wired connection to remote mesh router == wow!
Using the Linksys Atlas Max 6E
Joke: UnsafeWarnings
3/21/2023 • 24 minutes, 48 seconds
#327 Untangling XML with Pydantic
Watch on YouTube
About the show
Sponsored by Compiler Podcast from Red Hat.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: pydantic-xml extension
via Ilan
Recall untangle. How about some pydantic in the mix?
pydantic-xml is a pydantic extension providing model fields xml binding and xml serialization / deserialization. It is closely integrated with pydantic which means it supports most of its features.
Brian #2: How virtual environments work
Brett Cannon
This should be required reading for anyone learning Python.
Maybe right after “Hello World” and right before “My first pytest test”, approximately.
Some history of environments
Back in the day, there was global and your directory.
How environments work
structure: bin, include, and lib
pyvenv.cfg configuration file
How Python uses virtual environments
What activation does, and that it’s optional.
Yes, activation is optional.
A new project called microvenv that helps VS Code.
Mostly to fix the “Debian doesn’t ship python3 with venv” problem.
It doesn’t include script activation stuff
It’s super small, less than 100 lines of code, in one file.
Michael #3: DbDeclare
Declarative layer for your database.
https://raaidarshad.github.io/dbdeclare/guide/controller/#example
Sent in by creator raaid
DbDeclare is a Python package that helps you create and manage entities in your database cluster, like databases, roles, access control, and (eventually) more.
It aims to fill the gap between SQLAlchemy (SQLA) and infrastructure as code (IaC).
You can:
Declare desired state in Python
Avoid maintaining raw SQL
Tightly integrate your databases, roles, access control, and more with your tables
Migrations like alembic coming too.
Brian #4: Testing multiple Python versions with nox and pyenv
Seth Michael Larson
This is a cool “what to do first” with nox.
Specifically, how to use it to run pytest against your project on multiple versions of Python.
Example noxfile.py is super small
import nox
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"])
def test(session):
session.install(".")
session.install("-rdev-requirements.txt")
session.run("pytest", "tests/")
How to run everything, nox or nox -s test.
How to run single sessions, nox -s test-311 for just Python 3.11
Also how to get this to work with pyenv.
pyenv global 3.8 3.9 3.10 3.11 3.12-dev
This reminds me that I keep meaning to write a workflow comparison post about nox and tox.
Extras
Michael:
GitHub makes 2FA mandatory next week for active developers
New adventure bike [image 1, image 2].
Who’s got good ideas for where to ride in the PNW?
Wondering why I got it, here’s a fun video.
Joke: Case of the Mondays
3/13/2023 • 31 minutes, 37 seconds
#326 Let's Go for a PyGWalk
Watch on YouTube
About the show
Sponsored by Microsoft for Startups Founders Hub.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Data Classification : Does Python still have a need for class without @dataclass?
Glyph
dataclasses have been in the the language since 3.7
That’s pretty much all modern Python, right?
“…, is there any point to having non-@dataclass classes any more? Is there any remaining justification for writing them in new code?”
Options:
class just becomes a dataclass if you have typehinted members in it.
data instead of class, to avoid decorators
Michael #2: PyGWalker
Turn your pandas dataframe into a Tableau-style User Interface for visual analysis.
Works with pandas and polars
Open-source alternative to Tableau
It allows data scientists to analyze data and visualize patterns with simple drag-and-drop operations.
Brian #3: An opinionated Python boilerplate
Duarte O.Carmo
Tools and processes for new projects
pip-tools - Pip-tools strikes the right balance between simplicity, effectiveness, and speed.
especially for generating pinned requirements.txt files, if necessary
pyproject.toml - for configuration. packaging, but also any tool that supports it.
ruff
black, isort
no pre-commit hooks, just run it in CI
Michael #4: Front Matter VS Code
via Mark Little
If you have content that supports frontmatter and is markdown-based, check this out.
Stay in your editor and easily create, manage, and publish content.
Don’t make front matter mistakes
When was it published? What is the timezone text formatting again?
Learn new features of your existing static site (e.g. article image)
Manage images and more.
Extras
Brian:
VSCode improves IntelliSense support for pytest in Feb release
Michael:
AI search wars get weird
Proton Drive is Out of Beta, Available for Everyone
Joke:
Is your computer on? Is it on fire?
3/8/2023 • 33 minutes, 26 seconds
#325 It's called a merge conflict
Watch on YouTube
About the show
Sponsored by Microsoft for Startups Founders Hub.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: Python Parquet and Arrow: Using PyArrow With Pandas
Parquet is an efficient, compressed, column-oriented storage format for arrays and tables of data.
Less wrangle-able than Pandas, but way faster and lower memory
Questions answered
Can we use Pandas DataFrames and Arrow tables together, and if so, how is this done? (It turns out the answer is yes, and it’s quite simple, as we’ll see).
In what ways are Arrow tables “better” than Pandas DataFrames? In other words, for which tasks are Arrow tables better suited? Conversely, what tasks are possible or easy in Pandas that are difficult or impossible in Arrow?
As an on-disk format, how does Parquet compare to popular alternatives such as feather, orc, CSV, etc.?
Brian #2: FastAPI-Filter
Arthur Rio
Add query string filters to your api endpoints and show them in the swagger UI.
The supported backends are SQLAlchemy and MongoEngine.
FastAPI-Filter documentation
The philosophy of fastapi_filter is to be very declarative. You define the fields you want to be able to filter on as well as the type of operator, then tie your filter to a specific model.
default filters: neq, gt, gte, in, isnull, lt, lte, not/ne, not_in, nin, like/ilike
The swagger support is actually quite cool.
Michael #3: 12 Python Decorators to Take Your Code to the Next Level
Decorators are awesome
This is mostly home-grown decorators, but some standard ones too
Notable ones:
@warps
@lru_cache
@repeat
@timeit
@retry ← no please use tenacity
@countcall
@rate_limited
@dataclass
@register
@property
@singledispatch
Brian #4: PyHamcrest
Contributed by Txels
PyHamcrest is a framework for writing matcher objects, allowing you to declaratively define “match” rules.
PyHamcrest tutorial
Having a tool that allows you to pick out precisely the aspect under test and describe the values it should have, to a controlled level of precision, helps greatly in writing tests that are “just right.”
From Brian: I’ve been reluctant to try matcher style assertion helper libraries, as, with pytest, assert works just fine. However, I can see cases where PyHamcrest assertions could help test readability, and that’s always a win.
Examples:
equality: assert_that(theBiscuit, equal_to(myBiscuit))
exceptions: assert_that(calling(parse, bad_data), raises(ValueError))
async: assert_that(``**await** resolved(future), future_raising(ValueError))
boolean: assert_that(theBiscuit.isCooked())
There’s predefined matchers for
objects, numbers, text, logical checks, dequences, dictionaries
Extras
Brian:
pytest tips and tricks - recent post, and discussion on upcoming Talk Python episode
sharing pytest fixtures - placeholder page where I’ll share slides and code after my talk.
Michael:
Python runtime updates
Django 4.2 beta 1 released
Joke: A group of developers is called …
2/28/2023 • 39 minutes, 32 seconds
#324 JSON in My DB?
Watch on YouTube
About the show
Sponsored by Compiler Podcast from Red Hat.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Special guest, Erin Mullaney: @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Use TOML for .env files?
Brett Cannon
.env files are used to store default settings that can be overridden by environmental variables.
Possibly brought on by twelve-factor app design.
Supported by python-dotenv, which is also used by pydantic, pipenv, and others.
One issue is that it’s not a defined standard.
from python-dotenv docs “The format is not formally specified and still improves over time. That being said, .env files should mostly look like Bash files.”
Adafruit decided that an upcoming CircuitPython will use TOML as the format for settings.toml files, which are to be used mostly how .env files are being used.
Brett notices this may fix things for Python for VS Code, and other people as well.
So… Is this a good idea? I think so.
Michael #2: Pydantic gets serious funding
via Mark Little (was on episode 285)
Sequoia backs open source data-validation framework Pydantic to commercialize with cloud services.
Pydantic Services Inc. emerges from stealth today with $4.7 million in seed funding.
Pydantic’s new commercial entity will incorporate a swath of new tools and services that are both “powered-by and inspired-by the Pydantic library”
Pydantic will start with an initial team of six, with the first three engineers based in Montana, Chicago and Berlin.
“With $4.7 million in the bank, Colvin said that they’re continuing to rewrite parts of Pydantic in Rust, with a view toward making it more efficient via a ten-fold performance improvement.”
Erin #3: JSON Fields for performance (Denormalization)
David Stokes
Using JSON fields when you design your databases is a good way to improve database query performance.
Brian #4: f-strings with pandas and Jupyter keyboard shortcuts
Kevin Markham
After a couple year break from blogging, friend of the show Kevin Markham has a couple great, short, useful posts.
How to use Python's f-strings with pandas
My favorite bit is the part about using f-strings for dictionary keys
Fly through Jupyter with keyboard shortcuts 🚀
I’m a sucker for a rocket emoji
Not an overwhelming list. Just the essentials for even the casual Jupyter user.
Examples
Esc and Enter for command mode/edit mode
a and b for creating a new cell above or below current cell.
m and y for changing the cell type to Markdown or code.
Shift+m to merge cells
so many more
-
Michael #5: BioGPT
“GPT” for biomedical text generation and mining
As motivation, let’s see what ChatGPT can do with arrow anti-patterns in Python.
Smaller models and “Large” models
Used via an API rather than chat style.
BioGPT has also been integrated into the Hugging Face transformers library too
Play with it here.
Erin #6: Code Mentorship and Communicating with Newer Devs
Sheena O’Connell
Sheena O’Connell gave a talk at DjangoCon about her work at Umuzi, training unemployed young people in underserved communities in Africa and also was on Django Chat Podcast.
Dmitriy Chukhin
Caktus Group is trying a new mentorship program for folks who don’t have the necessary training.
Extras:
Michael:
News is, these are no loner news: Security Researchers Uncover 700+ Malicious Open-Source Packages in npm and PyPI
Git security vulnerabilities announced, again
git ignores
https://github.com/github/gitignore
https://gitignore.io
Erin:
DjangoCon is in October in Durham, NC this year (Oct 15-20)
Joke:
Remember your pointers?
2/21/2023 • 44 minutes, 53 seconds
#323 AI search wars have begun
Watch on YouTube
About the show
Sponsored by Microsoft for Startups Founders Hub.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected] - may be a minute or two late.
Show: @[email protected]
Special guest: Pamela Fox - @[email protected]
Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: camply
A tool to find campsites at sold out campgrounds through sites like recreation.gov and Yellowstone
Finding reservations at sold out campgrounds can be tough.
Searches the APIs of booking services like recreation.gov (which indexes thousands of campgrounds across the USA) to continuously check for cancellations and availabilities to pop up.
Once a campsite becomes available, camply sends you a notification to book your spot!
Want to camp in a tower in California?
camply campgrounds --search "Fire Lookout Towers" --state CA
Brian #2: hatch-fancy-pypi-readme
Your ✨Fancy✨ Project Deserves a ✨Fancy✨ PyPI Readme! 🧐
Hynek Schlawack
Include lots of extras in a README.md
text fragments
files, like AUTHORS.md or Changelog.md, with custom start, stop, pattern includes, etc.
regular expression substitutions
Several projects with examples, including black.
Pamela #3: Pyodide dev branch now supports 3.11
Python 3.11 PR
Benchmark Py3.11 and Py3.10
pyodide console
TODO list for 0.23.0 alpha release
Dis-this: specializing adaptive interpreter
Recursion visualizer
Michael #4: EU hates open source?
via Pamphile Roy
The Cyber Resilience Act (CRA) is an interesting and important proposal for a European law that aims to drive the safety and integrity of software
The proposal includes a requirement for self-certification by suppliers of software to attest conformity with the requirements of the CRA including security, privacy and the absence of Critical Vulnerability Events (CVEs).
We recognize that the European Commission has framed an exception in recital 10 attempting to ensure these provisions do not accidentally impact Open Source software.
However, drawing on more than two decades of experience, we at the Open Source Initiative can clearly see that the current text will cause extensive problems for Open Source software.
Since the goal is to avoid harming Open Source software this goal should be stated at the start of the paragraph as the rationale, replacing the introductory wording about avoiding harm to "research and innovation" to avoid over-narrowing the exception.
The reference to "non-commercial" as a qualifier should be substituted. The term “commercial” has always led to legal uncertainty for software and is a term which should not be applied in the context of open source
OSI recommends further work on the Open Source exception to the requirements within the body of the Act to exclude all activities prior to commercial deployment of the software and to clearly ensure that responsibility for CE marks does not rest with any actor who is not a direct commercial beneficiary of deployment.
Brian #5: So, Single (‘) or Double (“) Quotes in Python?
Marcin Kozak
PEP8 doesn’t recommend anything.
REPL uses single quotes.
>>> x = "one"
>>> x
'one'
Black sides with “double quotes”, due to the apostrophe in the string problem.
'Don\'t be so sad.' vs “Don’t be sad.”
You get to pick, and don’t be bullied by black-fanatics.
There’s always blue, which is just like black, but
defaults to single-quotes
line length defaults to 79, not black’s 88.
preserves whitespace before hash marks for right hanging comments (so multiple lines can line up).
Pamela #6: Frozen-Flask
Pamela’s PR for moving to Frozen Flask
Stepping down as a maintainer
Extras
Brian:
What does everyone think of GitHub pricing?
Michael:
Much much better transcripts, for example, this episode.
Means our search works way better too
The AI search wars have begun
- Google Panics Over ChatGPT [The AI Wars Have Begun] video
Microsoft Bing rockets to the top of the App Store after announcing ChatGPT integration
Google shares lose $100 billion after company's AI chatbot makes an error during demo
Free PyCharm for all the Talk Python customers
Thanks for the help with finding a good Flutter dev.
Important Talk Python episode: Fusion Ignition Breakthrough and Python
Pamela:
Github pyproject.toml support.
Python Package Template
Jokes:
$McTitle
Worst input fields
2/14/2023 • 50 minutes, 5 seconds
#322 Python Packages, Let Me Count The Ways
Watch on YouTube
About the show
Sponsored by Microsoft for Startups Founders Hub.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Special guest: @[email protected]
Join us on YouTube at pythonbytes.fm/stream/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: Packaging Python Projects
Tutorial from PyPA
This is a really good starting point to understand how to share Python code through packaging.
Includes discussion of
directory layout
creating package files, LICENSE, pyproject.toml, README.md, tests and src dir
how to fill out build-system section of pyproject.toml
using either hatchling, setuptools, flit, or pdm as backends
metadata
using build to generate wheels and tarballs
uploading with twine
However
For small-ish pure Python projects, I still prefer flit
flit init creates pyproject.toml and LICENSE
will probably still need to hand tweak pyproject.toml
flit build replaces build
flit publish replaces twine
The process can be confusing, even for seasoned professionals.
Further discussion later in the show
Michael #2: untangle xml
Convert XML to Python objects
Children can be accessed with parent.child, attributes with element['attribute'].
Call the parse() method with a filename, an URL or an XML string.
Given this XML:
[HTML_REMOVED]
[HTML_REMOVED]
[HTML_REMOVED]
[HTML_REMOVED]
Access the document:
obj.root.child['name'] # u'child1'
A little cleaner that ElementTree perhaps.
Calvin #3: Mypy 1.0 Released
Mypy is a static type checker for Python, basically a Python linter on steroids
Started in 2012 and developed by a team at Dropbox lead by https://github.com/JukkaL
What’s New?
New Release Numbering Scheme
not using symver
Significant backward incompatible changes will be announced in the blog post for the previous feature release
feature flags will allow users to upgrade and turn on the new behavior
Mypy 1.0 is 40% faster than 0.991 against the Dropbox internal codebase
20 optimizations included in this release
Mypy now warns about errors used before definition or possibly undefined variables
for example if a variable is used outside of a block of code that may not execute
Mypy now supports the new Self type introduced in PEP 673 and Python 3.11
Support ParamSpec in Type Aliases
Also, ParamSpec and Generic Self types are no loner experimental
Lots of Miscellaneous New Features
Fixes to crashes
Support for compiling Python match statements introduced in Python 3.10
Brian #4: Thoughts on the Python packaging ecosystem
Pradyun Gedam
Some great background on the internal tension around packaging.
Brian’s note: in the meantime
people are struggling to share Python code
the “best practice” answer seems to shift regularly
this might be healthy to arrive at better tooling in the long term, but in the short term, it’s hurting us.
From the article:
The Python packaging ecosystem unintentionally became the type of competitive space that it is today.
The community needs to make an explicit decision if it should continue operating under the model that led to status quo.
Pick from N different tools that do N different things is a good model.
Pick from N ~equivalent choices is a really bad user experience.
Picking a default doesn’t make other approaches illegal.
Communication about the Python packaging ecosystem is fragmented, and we should improve that.
Pradyun: “Many of the users who write Python code are not primarily full-time software engineers or “developers”.”
from Thea: “The reason there are so many tools for managing Python dependencies is because Python is not a monoculture and different folks need different things.”
opening up the build backend through pyproject.toml-based builds was good
but the fracturing of multiple “workflow” tools seems bad.
“I am certain that it is not possible to create a single “workflow” tool for Python software. What we have today, an ecosystem of tooling where each makes different design choices and technical trade-offs, is a part of why Python is as widespread as it is today. This flexibility and availability of choice is, however, both a blessing and a curse.”
On building a default workflow tool around pip
interesting idea
There’s tension between “we need a default workflow tool” and “unix philosophy: many focused tools that can work together”.
Michael #5: Top PyPI Packages
A monthly dump of the 5,000 most-downloaded packages from PyPI.
Also, a full copy of PyPI info too: github.com/orf/pypi-data
Calvin #6: SQLAlchemy 2.0 Released
#57 on the Top PyPI Packages 😸
Will be giving a SQLAlchemy tutorial at Python Web Conf
What’s New?
Significant API change from 1.4
You’ll want to follow the migration guide and see also the what’s new in 2.0 guide
Fully takes advantage of Python 3 features such as dataclasses, enums and inline annotations
Typing support in Core and ORM, but still should be considered beta
all SQLAlchemy stubs packages must be uninstalled all SQLAlchemy stubs packages must be uninstalled for typing to work
Mypy Plugin is considered deprecated now
Major speed increase in the all new fully ORM-integrated bulk INSERTs
sorry if you are on MySQL, they don’t support INSERT RETURNING yet
but MariaDB does support this
All new bulk optimized schema reflection architecture
Currently enabled for PostgreSQL and Oracle
250% perf increase for Postgres
900% per increase for Oracle
Native extensions ported to Cython
C extensions have been replaced by Cython
Benchmarks as fast or sometimes faster than the previous C extensions
Removes some risk of memory or stability issues introduced by C
SQLAlchemy is now pep-517 enabled and has a pyproject.toml at the root
means that local source building with pip can auto install the Cython dependancy
Extras
Brian:
Nothing to share yet, but I’m building a new alternative Python build backend.
which if course will be followed with a new workflow tool that follows “my workflow”.
Michael:
“Create shortcut: New window” tip:
In the dock/task bar
Running as an app
Speaking of Proton, started using simplelogin.io
What’s all this banning chips about? Great documentary
Talk Python is hiring!
Calvin:
5th Annual Python Web Conf 2023
2/7/2023 • 46 minutes, 40 seconds
#321 A Memorial To Apps Past
Watch on YouTube
About the show
Sponsored by Microsoft for Startups Founders Hub.
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/stream/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Michael #1: git-sim
Visually simulate Git operations in your own repos with a single terminal command.
Generates an image (default) or video visualization depicting the Git command's behavior.
Features
Run a one-liner git-sim command in the terminal to generate a custom Git command visualization (.jpg) from your repo
Supported commands: log, status, add, restore, commit, stash, branch, tag, reset, revert, merge, rebase, cherry-pick
Generate an animated video (.mp4) instead of a static image using the --animate flag (note: significant performance slowdown, it is recommended to use --low-quality to speed up testing and remove when ready to generate presentation-quality video)
Choose between dark mode (default) and light mode
Animation only: Add custom branded intro/outro sequences if desired
Animation only: Speed up or slow down animation speed as desired
See images and animations on the github readme.
Brian #2: Why I Like Nox
Hynek Schlawack
I like tox and have wanted to try nox but couldn’t think of good reasons for a switch.
Hynek is a fan of both, so it’s nice to read his perspective.
The article starts with comparing doing the same thing in both
testing with Python 3.10 and 3.11 and adding the ability to pass in pytest arguments.
even with this example, I do admit that the nox example is easier to read, but a bit more verbose.
A second example of running a specific example combination of library and Python is quite a bit longer in nox, but there’s an interesting commentary: “… this is longer than the tox equivalent. But that’s because it’s more explicit and anyone with a passing understanding of Python can deduce what’s happening here – including myself, looking at it in a year. Explicit can be good, actually.”
Other benefits:
It’s a Python file with Python functions, you have the all of Python at your disposal when developing sessions to run.
It’s not “ini format”. Complex ini files get out of hand quickly.
nox has Python versions as fist class selectors.
Final note: “Again, this article is not a call to abandon tox and move all your projects to Nox – I haven’t done that myself and I don’t plan to. But if my issues resonate with you, there’s an option!”
Michael #3: I scanned every package on PyPi and found 57 live AWS keys
Scanning every release published to PyPi found 57 valid access keys.
Detecting AWS keys is actually fairly simple. A keypair consists of two components: the key ID and the key secret.
The key ID can be detected with the regular expression ((?:ASIA|AKIA|AROA|AIDA)([A-Z0-7]{16}))
The secret key can be detected with a much more general [a-zA-Z0-9+/]{40}.
Static PyPI data: github.com/orf/pypi-data
Brian #4: Getting Started With Property-Based Testing in Python With Hypothesis and pytest
Rodrigo Girão Serrão
Hypothesis and property based testing can be overwhelming at first.
So focused intro posts are quite helpful.
This post focuses on a couple of examples, gcd(), greatest common divisor, and my_sort(), a custom list sorter.
Good discussion of how property based testing is different and how to do it successfully, especially the order of development:
focus on developing properties of correct answers
develop a test that checks those properties
use hypothesis strategies to come up with input
pick @examples if necessary
narrow the range of input if necessary
caveat: I would have preferred hypothesis.assume() to limiting input in the first example. assume(not (n == m == 0))
see https://hypothesis.readthedocs.io/en/latest/details.html#hypothesis.assume
add more testing outside of hypothesis
In my experience it’s often easier for me to develop code with non-hypothesis test cases, then follow up with hypothesis. But after works also.
The mental gymnastics of thinking of properties for algorithmic code is worthwhile.
Extras
Michael:
First stream from the sweet new mac mini.
Ivory released for Mastodon, but others too.
Nice memorial https://tapbots.com/tweetbot/
We’ll be doing a live in-person event at PyCon, become a friend of the show to get notified.
Joke: Didn't come here to be called out
1/30/2023 • 36 minutes, 30 seconds
#320 The Bug Is In The JavaScript
Watch on YouTube
About the show
Sponsored by us! Support our work through:
Our courses at Talk Python Training
Test & Code Podcast
Patreon Supporters
Connect with the hosts
Michael: @[email protected]
Brian: @[email protected]
Show: @[email protected]
Join us on YouTube at pythonbytes.fm/stream/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too.
Brian #1: markdown-it-py
Yes. another markdown parser.
Rich recently switched markdown parsers, from commonmark to markdown-it-py.
Let’s look at those a bit.
Michael #2: Sketch
via Jake Firman
Sketch is an AI code-writing assistant for pandas users that understands the context of your data
A Natural Language interface that successfully navigates many tasks in the data stack landscape.
Data Cataloging:
General tagging (eg. PII identification)
Metadata generation (names and descriptions)
Data Engineering:
Data cleaning and masking (compliance)
Derived feature creation and extraction
Data Analysis:
Data questions
Data visualization
Watch the video on the GitHub page for a quick intro
Brian #3: Fixing Circular Imports in Python with Protocol
Built on Subclassing in Python Redux from Hynek
We covered this in the summer of 2021, episode 240
However, I re-read it recently due to a typing problem
Problem is when an object passes itself to another module to be called later.
This is common in many design patterns, including just normal callback functions.
Normally not a problem with Python, due to duck typing.
But with type hints, suddenly it seems like both modules need types from the other.
So how do you have two modules use types from each other without a circular import.
Hynek produces two options
Abstract Data Types, aka Interfaces, using the abc module
Requires a third interface class
Structural subtyping with Protocol
This is what I think I’ll use more often and I’m kinda in love with it now that I understand it.
Still has a third type, but one of the modules doesn’t have to know about it.
"Structural Subtyping : Structural subtyping is duck typing for types: if your class fulfills the constraints of a [Protocol](https://docs.python.org/3/library/typing.html#typing.Protocol), it’s automatically considered a subtype of it. Therefore, a class can implement many Protocols from all kinds of packages without knowing about them!”
The Fixing Circular Imports in Python with Protocol article walks through one example of two classes talking with each other, typing, circular imports, and fixing them with Protocol
Michael #4: unrepl
via/by Ruud van der Ham
We’ve seen the code samples:
>>> board = []
>>> for i in range(3):
... row = ['_'] * 3
... board.append(row)
...
>>> board
[['_', '_', '_'], ['_', '_', '_'], ['_', '_', '_']]
>>> board\[2\][0] = 'X'
>>> board
[['_', '_', '_'], ['_', '_', '_'], ['X', '_', '_']]
But you cannot really run this code. You can’t paste it into a REPL yourself nor can you put it into a .py file.
So you unrepl it: Copying the above code to the clipboard and run unrepl.
Paste the result and now you can.
Unrepl can be used as a command line tool but also as a module.
The REPL functionality of underscore (_) to get access to the last value is also supported.
Extras
Michael:
You'll want to update your git ASAP.
Get course releases at Talk Python via RSS
Gist for using Turnstile with Python + Pydantic
Joke: there's a bug in the js
You’ve checked all your database indexes,
You’ve tuned all your API hooks,
You’re starting to think
That you might need a drink,
Because there’s only one place left to look:
…
There must be a bug in the javascript
Because everything else was built properly
But the frontend’s a pile of crap ;)
1/24/2023 • 28 minutes, 26 seconds
#319 CSS-Style Queries for... JSON?
See the full show notes for this episode on the website at pythonbytes.fm/319
1/18/2023 • 32 minutes, 44 seconds
#318 GIL, How We Will Miss You
See the full show notes for this episode on the website at pythonbytes.fm/318
1/10/2023 • 39 minutes, 38 seconds
#317 Most loved and most dreaded dev tools of 2022
See the full show notes for this episode on the website at pythonbytes.fm/317
1/3/2023 • 48 minutes, 31 seconds
#316 Python 3.11 is here and it's fast (crossover)
See the full show notes for this episode on the website at pythonbytes.fm/316
12/30/2022 • 1 hour, 4 minutes, 12 seconds
#315 Some Stickers!
See the full show notes for this episode on the website at pythonbytes.fm/315
12/20/2022 • 29 minutes, 56 seconds
#314 What are you, a wise guy? Sort it out!
See the full show notes for this episode on the website at pythonbytes.fm/314
12/13/2022 • 37 minutes, 24 seconds
#313 Programming Robots With a Marker
See the full show notes for this episode on the website at pythonbytes.fm/313
12/6/2022 • 46 minutes
#312 AI Goes on Trial For Writing Code
See the full show notes for this episode on the website at pythonbytes.fm/312
11/29/2022 • 35 minutes, 26 seconds
#311 Catching Memory Leaks with ... pytest?
See the full show notes for this episode on the website at pythonbytes.fm/311
11/24/2022 • 49 minutes, 50 seconds
#310 Calling All Tools for Readmes
See the full show notes for this episode on the website at pythonbytes.fm/310
11/15/2022 • 53 minutes, 44 seconds
#309 When Malware PoC's are Themselves Malware
See the full show notes for this episode on the website at pythonbytes.fm/309
11/9/2022 • 35 minutes, 1 second
#308 Conference season is heating up
See the full show notes for this episode on the website at pythonbytes.fm/308
11/1/2022 • 34 minutes, 37 seconds
#307 Your Python just got faster (3.11 is out!)
See the full show notes for this episode on the website at pythonbytes.fm/307
10/26/2022 • 44 minutes, 54 seconds
#306 Some Fun pytesting Tools
See the full show notes for this episode on the website at pythonbytes.fm/306
10/19/2022 • 46 minutes, 22 seconds
#305 Decorators need love too
See the full show notes for this episode on the website at pythonbytes.fm/305
10/13/2022 • 32 minutes, 58 seconds
#304 Build your own text adventure language in Python
See the full show notes for this episode on the website at pythonbytes.fm/304
10/5/2022 • 38 minutes, 24 seconds
#303 This title is required or is it optional?
See the full show notes for this episode on the website at pythonbytes.fm/303
9/29/2022 • 37 minutes, 56 seconds
#302 The Blue Shirt Episode
See the full show notes for this episode on the website at pythonbytes.fm/302
9/20/2022 • 33 minutes, 2 seconds
#301 PyTorch Grows Up and Moves Out
See the full show notes for this episode on the website at pythonbytes.fm/301
9/15/2022 • 31 minutes, 10 seconds
#300 A Jupyter merge driver for git
See the full show notes for this episode on the website at pythonbytes.fm/300
9/6/2022 • 55 minutes, 21 seconds
#299 Will McGugan drops by
See the full show notes for this episode on the website at pythonbytes.fm/299
9/3/2022 • 46 minutes, 7 seconds
#298 "Unstoppable" Python
See the full show notes for this episode on the website at pythonbytes.fm/298
8/24/2022 • 32 minutes, 22 seconds
#297 I AM the documentation
See the full show notes for this episode on the website at pythonbytes.fm/297
8/16/2022 • 22 minutes, 36 seconds
#296 pip: Constrain your excitement
See the full show notes for this episode on the website at pythonbytes.fm/296
8/9/2022 • 32 minutes, 31 seconds
#295 Flutter + Python GUI Apps?
See the full show notes for this episode on the website at pythonbytes.fm/295
8/4/2022 • 36 minutes, 16 seconds
#294 Specializing Adaptive Interpreters in Full Color
See the full show notes for this episode on the website at pythonbytes.fm/294
7/26/2022 • 35 minutes, 26 seconds
#293 And if I pull this open source Jenga block...
See the full show notes for this episode on the website at pythonbytes.fm/293
7/20/2022 • 47 minutes, 34 seconds
#292 Thursday, it's always a Thursday
See the full show notes for this episode on the website at pythonbytes.fm/292
7/11/2022 • 28 minutes, 36 seconds
#291 Wait, you have how many licenses?!?
See the full show notes for this episode on the website at pythonbytes.fm/291
7/6/2022 • 32 minutes, 27 seconds
#290 Sentient AI? If so, then what?
See the full show notes for this episode on the website at pythonbytes.fm/290
6/28/2022 • 49 minutes, 34 seconds
#289 Textinator is coming for your text, wherever it is
See the full show notes for this episode on the website at pythonbytes.fm/289
6/21/2022 • 46 minutes, 14 seconds
#288 Performance benchmarks for Python 3.11 are amazing
See the full show notes for this episode on the website at pythonbytes.fm/288
6/14/2022 • 33 minutes, 5 seconds
#287 Surprising ways to use Jupyter Notebooks
See the full show notes for this episode on the website at pythonbytes.fm/287
6/7/2022 • 27 minutes, 22 seconds
#286 Unreasonable f-strings
See the full show notes for this episode on the website at pythonbytes.fm/286
6/3/2022 • 26 minutes, 22 seconds
#285 Where we talk about UIs and Python
See the full show notes for this episode on the website at pythonbytes.fm/285
5/25/2022 • 50 minutes, 54 seconds
#284 Spicy git for Engineers
See the full show notes for this episode on the website at pythonbytes.fm/284
5/18/2022 • 41 minutes, 12 seconds
#283 The sports episode
See the full show notes for this episode on the website at pythonbytes.fm/283
5/12/2022 • 32 minutes, 58 seconds
#282 Don't Embarrass Me in Front of The Wizards
See the full show notes for this episode on the website at pythonbytes.fm/282