4 - Python Scripting

BASH and other scripting languages are fantastic in the shell and for quick or OS-specific scripts. But what if you want something a little more powerful and cross-platform?

What are we learning?

In this lesson we will:

Run Commands

When you give arguments to a program that modify how the program works, these are sometimes called run commands. Some programs can store these options in a configuration file.
.bashrc

.nanorc

Nano can also take run commands to modify how it works. 

Let's change tabs to spaces and a couple other things...

Python

BASH is powerful but it's more of an operating system scripting language - for talking to the kernel, making and reading files, etc... What if we want to write a program that is cross-platform and portable-ish?

Python is the Swiss army knife of scripting languages. It's not amazing at one thing - it's pretty good at all things. It's also a popular platform for learning, data analysis, and sharing libraries of code that do cool things.

Let's check if Python is installed:

Python Treats

Let's recreate the Dog Treats program we wrote in BASH:

Zero That Out

In the EXTRAS section of the first class task was the description of a boss who would give numbers to sum but if the boss made a mistake they would say the number zero meaning to not use the last number. Can we recreate the program in Python? Would this be easier than in BASH?

Reference:  Python Tutorial (w3)