Python Comments and Docstrings

By | Engineering

There’s one special comment called a ‘shebang’ that python scripts can start #! /usr/bin/env python3 Having this source code allows you execute the python file. First you need to make the file executable with the following chmod +x example.py to allow it to be invoked from command line without having to specify the interpreter to run it. If you have…

Read More

Python Command Line Args

By | Engineering

Command line arguments are the string of data and flags that are passed into a python script for execution to change behavior. You leverage the built-in sys module to get access to the sys.argv list. python example.py my name is david Number of arguments: 5 Argument List: [‘example.py’, ‘my’, ‘name’, ‘is’, ‘david’] The built-in getopt module can help parse command…

Read More