Skip to Main Content
Python Command Line Tools
book

Python Command Line Tools

by Alfredo Deza, Noah Gift
May 2020
Intermediate to advanced content levelIntermediate to advanced
117 pages
1h 57m
English
Pragmatic AI Labs
Content preview from Python Command Line Tools

Chapter 5: Writing pure Bash or ZSH command-line tools

Alfredo Deza

I’ve been horrified before trying to figure out a piece of production code that was mixing shell scripting and Python. Why would one try to do something like this? A step further was when a large (and custom) Python test framework was doing a system call to a shell that then itself executed Python on a remote system. Can you imagine fixing bugs in that codebase? Where do you start? In the remote server running some odd version of Python, or using a previous version of BASH that has a built-in that behaves differently? Or perhaps in Python that can change some subtle things (like dictionary ordering) from one version to the other?

    writes = run(
        args=[
            'sudo', 'mkdir', 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python CI/CD for the Command-Line

Python CI/CD for the Command-Line

Alfredo Deza, Noah Gift
Intuitive Python

Intuitive Python

David Muller
Learning Python Networking - Second Edition

Learning Python Networking - Second Edition

José Manuel Ortega, Dr. M. O. Faruque Sarker, Sam Washington

Publisher Resources

ISBN: 61619PAIMLPurchase LinkOtherOtherOther