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

Episode #280: Easy terminal scripts by sourcing your Py

Published Thu, Apr 21, 2022, recorded Tue, Apr 19, 2022.


Watch the live stream:


About the show

Sponsored by Mergify!

Special guest: Pat Decker

Michael #0: New live stream / recording time: 12pm US PT on Tuesdays. Please subscribe to our YouTube channel to get notified and be part of the episodes.

Brian #1: BTW, don’t make a public repo private

  • How we lost 54k GitHub stars
    • Jakub Roztočil
    • HTTPie kinda sorta accidentally flipped their main repo to private for a sec.
    • And dropped the star count from 54k to 0
    • oops
    • They’re back up to 16k, as of today. But ouch.
  • “HTTPie is a command-line HTTP client. Its goal is to make CLI interaction with web services as human-friendly as possible. HTTPie is designed for testing, debugging, and generally interacting with APIs & HTTP servers. The http & https commands allow for creating and sending arbitrary HTTP requests. They use simple and natural syntax and provide formatted and colorized output.”
  • Actually, pretty cool tool to use for developing and testing APIs.

Michael #2: The counter-intuitive rise of Python in scientific computing

  • via Galen Swint
  • In our laboratory, a polarizing debate rages since around 2010, summarized by this question: Why are more and more time-critical scientific computations formerly performed in Fortran now written in Python, a slower language?
  • Python has the reputation of being slow, i.e. significantly slower than compiled languages such as Fortran, C or Rust.
  • So yes, plain Python is much slower than Fortran.
  • However, this comparison makes little sense, as scientific uses of Python do not rely on plain Python.
  • Used the right way, Python is slightly slower than compiled code.

Pat #3:

Brian #4: Dashboards in Python

  • Two suggestions from Marc Skov Madsen
  • The Easiest Way to Create an Interactive Dashboard in Python
    • Sophia Yang & Mark Skov Madsen
    • Includes
      • animated gif showing the dashboard
      • video of Sophia walking through the article in under 6 minutes
    • “Turn Pandas pipelines into a dashboard using hvPlot .interactive"
    • hvPlot is part of HoloViz and this example is pretty short and amazing to get a great dashboard with controls up very quickly.
  • Python Dashboarding Shootout and Showdown | PyData Global 2021
    • 5 speakers, 4 dashboard libraries, nice for comparison.
    • Nice clickable index posted by Duy Nguyen
      • 00:00 - Begin and Welcome
      • 03:15 - Intro to the 4 Dashboarding libraries
      • 07:04 - Plotly - Nicolas Kruchten
      • 22:01 - Panel - Marc Skov Madsen
      • 37:38 - voila - Sylvain Corlay
      • 51:36 - Streamlit - Adrien Treuille
      • 01:10:52 - Discussion Topics

Michael #5: sourcepy

  • by Dave Chevell
  • Sourcepy lets you source python scripts natively inside your shell
  • Imagine a Python script with functions in it. This converts those to CLI commands (kind of like entrypoints, but simpler)
  • Type hints can be used to coerce input values into their corresponding types.
  • standard IO type hints can be used to target stdin at different arguments and to receive the sys.stdin
  • Sourcepy has full support for asyncio syntax

Pat #6: Xonsh

Extras

Pat:

Joke: Can you really quit vim?

Joke: Forgetting how to count


Want to go deeper? Check our projects