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.
Similar Podcasts

24H24L
Evento en línea, de 24 horas de duración que consiste en la emisión de 24 audios de diversas temáticas sobre GNU/Linux. Estos son los audios del evento en formato podcast.

The Infinite Monkey Cage
Brian Cox and Robin Ince host a witty, irreverent look at the world through scientists' eyes.

Talking Kotlin
A bimonthly podcast that covers the Kotlin programming language by JetBrains, as well as related technologies. Hosted by Hadi Hariri
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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.
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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?
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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 @brianokken@fosstodon.org 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!
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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
#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: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org 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