Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

#328: We are going to need some context here

Published Tue, Mar 21, 2023, recorded Tue, Mar 21, 2023
Watch this episode on YouTube
Play on YouTube
Watch the live stream replay

About the show

Sponsored by Microsoft for Startups Founders Hub.

Connect with the hosts

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
  • 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:

Michael:

Joke: UnsafeWarnings


Want to go deeper? Check our projects