A Python learning path for network engineers

November 30, 2020

Python programming is now a required skill for network engineers. I recorded videos of myself as I learned and practiced Python programming. I think these videos, along with the links to learning resources associated with each video’s topic, serve as a good learning guide for network engineers getting started with Python programming.

This post collects links to all ten videos I created. Over the course of these videos, I wrote a program called Usermapper that reads a configuration file and builds an XML authentication file for the Guacamole web proxy. I also used the Git version control system and posted the code in my Usermapper GitHub repository

Topics I need to learn

I learned some programming during my Electrical Engineering degree program many years ago. After I graduated, except for some basic scripting, I’ve not had to do any programming.

These videos do not cover the basics of Python. I strongly suggest you read a book about Python, or watch some video training (see suggestions below) before you start working through these videos. Before I started recording this first video, I read the O’Reilly book, Learning Python, and wrote a blog post about what I learned in the first part of the book.

This video refers to the following resources:

My first Python program

In this video, I write the first part of a program that will build a user authentication file that is compatible with the Apache Guacamole web proxy server. The output file will eventually be in XML format but this first version creates a Python dictionary populated with all the required information.

As I wrote this code, I learned more about the modules and packages available in Python’s standard library. I also got some good practice with the Python Object Model as it relates to copying opjects and references to objects.

I mention the following resources in this video:

Writing an XML file

In my previous video, I created a nested dictionary containing the raw data that must be written, in XML format, to the user mapping file. In this video, I add the code that writes an XML file based on that dictionary’s contents. I solve problems like parsing through several layers of a nested dictionary to modify values.

I mention the following resources in this video:

Reorganizing my program

In this video, I’ll explore a bit more about Python by organizing my current project into functions and modules to make it easier to maintain.

My project currently consists of one file and the data used to build the XML output file is hard-coded into the program. This is not very flexible and makes it hard for others to use the program. First I will divide the project into module files and then turn some of the program logic into functions.

I mention the following resources in this video:

Git and GitHub

In this video, I use the Git version control system to manage changes to my code and also create a remote repository on Github.

Before watching this video, I recommend you review the following:

Other resources I mention in this video are:

Python virtual environments

In this video, I start making my first program more flexible. I define the input in a configuration file. I learn the YAML file format. I introduce Python virtual environments. Also, I get more practice using Git as I make my code changes.

Before watching this video, I recommend you review the following:

Other resources I mention in this video are:

Rewriting mapperdata.py

In this video, I continue making my first program more flexible. I use a Python virtual environment. I install the PyYAML package using pip. I rewrite my mapperdata.py module to read the YAML config file and build a data structure based on its contents. I make a few classic mistakes while iterating through nested dictionaries and I introduce the useful git restore command.

Before watching this video, I recommend you review the following:

Other resources I mention in this video are:

Using VS Code

In this video, I finish rewriting my mapperdata.py module to read the YAML config file and build a data structure based on its contents. I also introduce the Visual Studio Code text editor, which I’ll be using from now on.

Before watching this video, I recommend you review the following short videos:

Other resources I mention in this video are:

Requirements.txt and using GitHub Issues

In this video, I create a requirements.txt file so others can easily deploy the Usermapper application. I also fix a bug I found in the program. I use GitHub Issues to save notes about improvements I would like to make to the application, if I find time in the future. Finally, I discuss what I think it will take to learn enough about the Flask framework so I can move on to the next step.

Resources I mention in this video are:

Packaging and command-line arguments

In this video, I organize my Python modules into a package that others can download and install. I also modify the program so users can specify the input file and output file locations and filenames in command line arguments. The final result is at: https://github.com/blinklet/usermapper.git

Before watching this video, I recommend you read the following article:

Other resources I mention in this video are:

Conclusion

Over the course of a month, I spend about one hour per evening learning and practicing Python. I found that choosing a specific project to implement in Python helped me learn. If you administer a Guacamole web proxy server, have a look at my Usermapper program! I am now looking forward to learning the Flask framework and building a web site using Python.

Trackbacks and Pingbacks:

  1. Flask web app tutorial for network engineers | Open-Source Routing and Network Simulation - December 18, 2020

    […] previously wrote a blog post describing The Minimum You Need to Know About Python and created a YouTube playlist about building Usermapper, my first useful Python […]