Brought to you by DigitalOcean - grab your $50 credit and deploy your first project for free

Episode #142: There's a bandit in the Python space

Published Tues, Aug 6, 2019, recorded Wed, Jul 31, 2019.

Special guest: Brett Thomas

Sponsored by Datadog: pythonbytes.fm/datadog

Brian #1: Writing sustainable Python scripts

  • Vincent Bernat
  • Turning a quick Python script into a maintainable bit of software.
  • Topics covered:
    • Documentation as a docstring helps future users/maintainers know what problem you are solving.
    • CLI arguments with defaults instead of hardcoded values help extend the usability of the script.
    • Logging. Including debug logging (and how to turn them on with CLI arguments), and system logging for unattended scripts.
    • Tests. Simple doctests, and pytest tests utilizing parametrize to have one test and many test cases.

Brett #2: Static Analysis and Bandit

Michael #3: jupyter-black

  • Black formatter for Jupyter Notebook
  • One of the big gripes I have about these online editors is their formatting (often entirely absent)
  • Then the extension provides
    • a toolbar button
    • a keyboard shortcut for reformatting the current code-cell (default: Ctrl-B)
    • a keyboard shortcut for reformatting whole code-cells (default: Ctrl-Shift-B)

Brian #4: Report Generation workflow with papermill, jupyter, rclone, nbconvert, …

Brett #5: Rant on time deltas

Michael #6: How — and why — you should use Python Generators

  • by Radu Raicea
  • Generator functions allow you to declare a function that behaves like an iterator.
  • They allow programmers to make an iterator in a fast, easy, and clean way.
  • They only compute it when you ask for it. This is known as lazy evaluation.
  • If you’re not using generators, you’re missing a powerful feature
  • Often they result in simpler code than with lists and standard functions

Extras

Brian:

Michael:

Jokes

A good programmer is someone who always looks both ways before crossing a one-way street.

(reminds me of another joke: Adulthood is like looking both ways before crossing the street, then getting hit by an airplane)

Little bobby tables


Click to show comments