Podbean logo
  • Discover
  • Podcast Features
    • Podcast Hosting

      Start your podcast with all the features you need.

    • Podbean AI Podbean AI

      AI-Enhanced Audio Quality and Content Generation.

    • Blog to Podcast

      Repurpose your blog into an engaging podcast.

    • Video to Podcast

      Convert YouTube playlists to podcasts, videos to audios.

  • Monetization
    • Ads Marketplace

      Join Ads Marketplace to earn through podcast sponsorships.

    • PodAds

      Manage your ads with dynamic ad insertion capability.

    • Apple Podcasts Subscriptions Integration

      Monetize with Apple Podcasts Subscriptions via Podbean.

    • Live Streaming

      Earn rewards and recurring income from Fan Club membership.

  • Podbean App
    • Podcast Studio

      Easy-to-use audio recorder app.

    • Podcast App

      The best podcast player & podcast app.

  • Help and Support
    • Help Center

      Get the answers and support you need.

    • Podbean Academy

      Resources and guides to launch, grow, and monetize podcast.

    • Podbean Blog

      Stay updated with the latest podcasting tips and trends.

    • What’s New

      Check out our newest and recently released features!

    • Podcasting Smarter

      Podcast interviews, best practices, and helpful tips.

  • Popular Topics
    • How to Start a Podcast

      The step-by-step guide to start your own podcast.

    • How to Start a Live Podcast

      Create the best live podcast and engage your audience.

    • How to Monetize a Podcast

      Tips on making the decision to monetize your podcast.

    • How to Promote Your Podcast

      The best ways to get more eyes and ears on your podcast.

    • Podcast Advertising 101

      Everything you need to know about podcast advertising.

    • Mobile Podcast Recording Guide

      The ultimate guide to recording a podcast on your phone.

    • How to Use Group Recording

      Steps to set up and use group recording in the Podbean app.

  • All Arts Business Comedy Education
  • Fiction Government Health & Fitness History Kids & Family
  • Leisure Music News Religion & Spirituality Science
  • Society & Culture Sports Technology True Crime TV & Film
  • Live
  • How to Start a Podcast
  • How to Start a Live Podcast
  • How to Monetize a podcast
  • How to Promote Your Podcast
  • How to Use Group Recording
  • Log in
  • Start your podcast for free
  • Podcasting
    • Podcast Features
      • Podcast Hosting

        Start your podcast with all the features you need.

      • Podbean AI Podbean AI

        AI-Enhanced Audio Quality and Content Generation.

      • Blog to Podcast

        Repurpose your blog into an engaging podcast.

      • Video to Podcast

        Convert YouTube playlists to podcasts, videos to audios.

    • Monetization
      • Ads Marketplace

        Join Ads Marketplace to earn through podcast sponsorships.

      • PodAds

        Manage your ads with dynamic ad insertion capability.

      • Apple Podcasts Subscriptions Integration

        Monetize with Apple Podcasts Subscriptions via Podbean.

      • Live Streaming

        Earn rewards and recurring income from Fan Club membership.

    • Podbean App
      • Podcast Studio

        Easy-to-use audio recorder app.

      • Podcast App

        The best podcast player & podcast app.

  • Advertisers
  • Enterprise
  • Pricing
  • Resources
    • Help and Support
      • Help Center

        Get the answers and support you need.

      • Podbean Academy

        Resources and guides to launch, grow, and monetize podcast.

      • Podbean Blog

        Stay updated with the latest podcasting tips and trends.

      • What’s New

        Check out our newest and recently released features!

      • Podcasting Smarter

        Podcast interviews, best practices, and helpful tips.

    • Popular Topics
      • How to Start a Podcast

        The step-by-step guide to start your own podcast.

      • How to Start a Live Podcast

        Create the best live podcast and engage your audience.

      • How to Monetize a Podcast

        Tips on making the decision to monetize your podcast.

      • How to Promote Your Podcast

        The best ways to get more eyes and ears on your podcast.

      • Podcast Advertising 101

        Everything you need to know about podcast advertising.

      • Mobile Podcast Recording Guide

        The ultimate guide to recording a podcast on your phone.

      • How to Use Group Recording

        Steps to set up and use group recording in the Podbean app.

  • Discover
  • Log in
    Sign up free
Python Bytes

Python Bytes

Technology

#249 All of Linux as a Python API

#249 All of Linux as a Python API

2021-09-09
Download Right click and do "save link as"

Watch the live stream:

Watch on YouTube

About the show

Sponsored by us:

  • Check out the courses over at Talk Python
  • And Brian’s book too!

Special guest: Erik Christiansen

Michael #1: Fickling

  • via Oli
  • A Python pickling decompiler and static analyzer
  • Pickled ML models are becoming the data exchange and workflow of ML
  • Analyses pickle files for security risks - It can also remove or insert [malicious] code into pickle files...
  • Created by a security firm, it can be a useful defensive or offensive tool.
  • Perhaps it is time to screen all pickles?
>>> import ast >>> import pickle >>> from fickling.pickle import Pickled >>> print(ast.dump(Pickled.load(pickle.dumps([1, 2, 3, 4])).ast, indent=4)) Module( body=[ Assign( targets=[ Name(id='result', ctx=Store())], value=List( elts=[ Constant(value=1), Constant(value=2), Constant(value=3), Constant(value=4)], ctx=Load()))])
  • You can test for common patterns of malicious pickle files with the --check-safety option
  • You can also safely trace the execution of the Pickle virtual machine without exercising any malicious code with the --trace option.
  • Finally, you can inject arbitrary Python code that will be run on unpickling into an existing pickle file with the --inject option.
  • See Risky Biz's episode for more details.

Brian #2: Python Project-Local Virtualenv Management

  • Hynek Schlawack
  • Only works on UNIX-like systems. MacOS, for example.
  • Instructions
    • Install direnv. (ex: brew install direnv)
    • Put this into a .envrc file in your project root:
    • layout python python3.9
  • Now
    • when you cd into that directory or a subdirectory, your virtual environment is loaded.
    • when you cd out of it, the venv is unloaded
  • Notes:
    • Michael covered direnv on Episode 185. But it wasn’t until Hynek spelled it out for me how to use it with venv that I understood the simplicity and power.
    • Not really faster than creating a venv, but when flipping between several projects, it’s way faster than deactivating/activating.
    • You can also set env variables per directory (kinda the point of direnv)

Erik #3: Testcontainers

“Python port for testcontainers-java that allows using docker containers for functional and integration testing. Testcontainers-python provides capabilities to spin up docker containers (such as a database, Selenium web browser, or any other container) for testing. “ (pypi description).

  • Provides cloud native services, many databases and the like (e.g. Google Cloud Pub/Sub, Kafka..)
  • Originally a java project, still a way to go for us python programmers to implement all services
  • Provides an example for use in CI/CD by leveraging Docker in Docker
import sqlalchemy from testcontainers.mysql import MySqlContainer with MySqlContainer('mysql:5.7.17') as mysql: engine = sqlalchemy.create_engine(mysql.get_connection_url()) version, = engine.execute("select version()").fetchone() print(version) # 5.7.17

Michael #4: jc

  • via Garett
  • CLI tool and python library that converts the output of popular command-line tools and file-types to JSON or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
  • Run it as COMMAND ARGS | jc --COMMAND
  • Commands include: systemctl, passwd, ls, jobs, hosts, du, and cksum.

Brian #5: What is Python's Ellipsis Object?

  • Florian Dahlitz
  • Ellipsis or … is a constant defined in Python
    • “Ellipsis: The same as the ellipsis literal “...”. Special value used mostly in conjunction with extended slicing syntax for user-defined container data types.”
  • Can be used in type hinting
    • Func returns two int tuple
def return_tuple() -> tuple[int, int]: pass
  • Func returns one or more integer:
def return_tuple() -> tuple[int, ...]: pass
  • Replacement for pass:
def my_function(): ...
  • Ellipsis in the wild, “if you want to implement a certain feature where you need a non-used literal, you can use the ellipsis object.”
    • FastAPI : Ellipsis used to make parameters required
    • Typer: Same

Erik #6: PyTorch Forecasting PyTorch Forecasting aims to ease state-of-the-art timeseries forecasting with neural networks for both real-world cases and research alike. The goal is to provide a high-level API with maximum flexibility for professionals and reasonable defaults for beginners.

  • basically tries to achieve for time series what fast.ai has achieved for computer vision and natural language processing
  • The package is built on PyTorch Lightning to allow training on CPUs, single and multiple GPUs out-of-the-box.
  • Implements of Temporal Fusion Transformers
    • interpretable - can calculate feature importance
  • Hyperparameter tuning with optuna

Extras

Brian

  • Python 3.10rc2 available. 3.10 is about a month away

Michael

  • GoAccess follow up
  • Caffinate more - via Nathan Henrie: you mentioned the MacOS /usr/bin/caffeinate tool on "https://pythonbytes.fm/episodes/show/247/do-you-dare-to-press-.". Follow caffeinate with long-running command to keep awake until done (caffeinate python -c 'import time; time.sleep(10)'), or caffeinate -w "$PID" for an already running task.
  • Python Keyboard (via Sean Tabor)
  • Open source is booming (via Mark Little)
  • FFMPEG.WASM ffmpeg.wasm is a pure WebAssembly via Jim Anderson
  • Everything is fine: PyPI packages
  • Python 3.10 RC 2 is out

Joke: 200 == 400

view more

More Episodes

#299 Will McGugan drops by
2022-09-03
#298 "Unstoppable" Python
2022-08-24
#297 I AM the documentation
2022-08-16
#296 pip: Constrain your excitement
2022-08-09
#295 Flutter + Python GUI Apps?
2022-08-04
#294 Specializing Adaptive Interpreters in Full Color
2022-07-26
#293 And if I pull this open source Jenga block...
2022-07-20
#292 Thursday, it's always a Thursday
2022-07-11
#291 Wait, you have how many licenses?!?
2022-07-06
#290 Sentient AI? If so, then what?
2022-06-28
#289 Textinator is coming for your text, wherever it is
2022-06-21
#288 Performance benchmarks for Python 3.11 are amazing
2022-06-14
#287 Surprising ways to use Jupyter Notebooks
2022-06-07
#286 Unreasonable f-strings
2022-06-03
#285 Where we talk about UIs and Python
2022-05-25
#284 Spicy git for Engineers
2022-05-18
#283 The sports episode
2022-05-12
#282 Don't Embarrass Me in Front of The Wizards
2022-05-03
#281 ohmyzsh + ohmyposh + mcfly + pls + nerdfonts = wow
2022-04-28
#280 Easy terminal scripts by sourcing your Py
2022-04-21
  • ←
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • →
012345678910111213141516171819

Get this podcast on your
phone, FREE

Download Podbean app on App Store Download Podbean app on Google Play

Create your
podcast in
minutes

  • Full-featured podcast site
  • Unlimited storage and bandwidth
  • Comprehensive podcast stats
  • Distribute to Apple Podcasts, Spotify, and more
  • Make money with your podcast
Get started

It is Free

  • Podcast Services

    • Podcast Features
    • Pricing
    • Enterprise Solution
    • Private Podcast
    • The Podcast App
    • Live Stream
    • Audio Recorder
    • Remote Recording
    • Podbean AI
  •  
    • Create a Podcast
    • Video Podcast
    • Start Podcasting
    • Start Radio Talk Show
    • Education Podcast
    • Church Podcast
    • Nonprofit Podcast
    • Get Sermons Online
    • Free Audiobooks
  • MONETIZATION & MORE

    • Podcast Advertising
    • Dynamic Ads Insertion
    • Apple Podcasts Subscriptions
    • Switch to Podbean
    • YouTube to Podcast
    • Blog to Podcast
    • Submit Your Podcast
    • Podbean Plugins
    • Developers
  • KNOWLEDGE BASE

    • How to Start a Podcast
    • How to Start a Live Podcast
    • How to Monetize a Podcast
    • How to Promote Your Podcast
    • Mobile Podcast Recording Guide
    • How to Use Group Recording
    • Podcast Advertising 101
  • Support

    • Support Center
    • What’s New
    • Free Webinars
    • Podcast Events
    • Podbean Academy
    • Podbean Amplified Podcast
    • Badges
    • Resources
  • Podbean

    • About Us
    • Podbean Blog
    • Careers
    • Press and Media
    • Green Initiative
    • Affiliate Program
    • Contact Us
  • Privacy Policy
  • Cookie Policy
  • Terms of Use
  • Consent Preferences
  • Copyright © 2015-2025 Podbean.com