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.

#268 Wait, you can Google that?

January 27, 2022 00:45:09 38.78 MB Downloads: 0

Watch the live stream:

Watch on YouTube

About the show

Sponsored by us:

Special guest: Madison @AetherUnbound

Brian #1: (draft) PEP 679 -- Allow parentheses in assert statements

  • Pablo Galindo Salgado
  • This is in draft, not approved, and not scheduled for any release
  • But it seems like a really good idea to me.
  • assert(1 == 2, "seems like it should fail") will always pass currently
  • since the tuple (False,"seems like it should fail") is a non-empty tuple.
  • Current Python will emit a warning
    >>> assert(1 == 2, "seems like it should fail")
    [stdin]:1: SyntaxWarning: assertion is always true, perhaps remove parentheses?
  • But really, why not just change the language to allow assert with or without parens.
  • Also would allow multi-line assert statements more easily:
    assert (
        very very long
        expression,

        "very very long "
        "message",
    )
  • I hope this is a slam dunk and gets in ASAP.

Michael #2: Everything I googled as a dev

  • by Sophie Koonin
  • In an attempt to dispel the idea that if you have to google stuff you’re not a proper engineer, this is a list of nearly everything I googled in a week at work
  • Rather than my posting a huge list, check out the day logs on her post
  • Worth calling out a few:
    • Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? - said React upgrade then started causing some super fun errors.
    • semantic HTML contact details - wanted to check if the [HTML_REMOVED] tag was relevant here
    • editing host file - desperate times (and it didn’t even work)

Madison #3: PyCascades 2022!

Brian #4: Strict Python function parameters

  • Seth Michael Larson
  • We have keyword only parameters
    • def process_data(data, *, encoding="ascii"): ...
    • notice the *
    • encoding has to be a keyword argument, cannot be positional.
  • We have position only parameters:
    • def process_data(data, /, encoding="ascii"): ...
    • notice the /
    • data has to be positional, cannot be passed in as a keyword argument
  • Combine the two:
    • def process_data(data, /, *, encoding="ascii"): ...
    • Now data has to be positional, and encoding has to be a keyword, if present.
  • This way a function really can only be called as intended and all uses of the function will be consistent. This is a good thing.
  • There are many benefits, including empowering library authors to make changes without weird behaviors cropping up in user code.
  • Commentary:
    • extra syntax may be confusing for some new users.
    • For a lot of library API entry points, I think this makes a lot of sense.

Michael #5: mureq - vendored requests

  • mureq is a single-file, zero-dependency alternative to python-requests
  • Intended to be vendored in-tree by Linux systems software and other lightweight applications.
  • Doesn’t support connection pooling (but neither does requests.get()).
  • Uses much less memory
  • Avoids supply chain attack vulnerabilities
  • Consider my prod branch until PRs #2 and #3 are merged.

Madison #6: Openverse

Extras

Michael:

Brian:

  • pip-secure-install - from Brett Cannon
  • Python Testing with pytest is, when I last checked, the #2 bestseller at Pragmatic
    • so cool
    • My Maui trip was also a work trip. Gave me time to completely re-read the book, make notes, and make last minute changes. Changes went in this week and tonight is my “pencils down” date. This is getting real, folks.
    • Thanks to everyone for buying beta copies and supporting the re-write.

Madison:

  • spd.watch - new police accountability/information tool for the Seattle area
  • Shoutout to just (mentioned in Ep 242)
  • ghcr.io - free docker image hosting for open source projects, easy integration with GitHub Actions

Joke:

via Josh Thurston

  • How did the hacker get away from the police? He just ransomware.
  • That joke makes me WannaCry…
  • Where do you find a hacker? In decrypt.