Video Learning Path for Python Programming
Posted on Mon 30 November 2020 in Python
I recorded videos 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 packaged the code on 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:
- The Learning Python book, by Mark Lutz
- Microsoft's Introduction to Python Development videos
- Microsoft's More Python for Beginners videos
- A Python style guide
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:
- Copying Python objects
- Shallow copy vs Deep copy
- The Python standard library.
- The Guacamole default authentication file format
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:
- Getting started with Git videos (20 minutes total)
- GitHub guides videos: The getting-started playlist
Other resources I mention in this video are:
- The git documentation
- Git cheat sheet
- GitHub First Contributions repo
- Another good guide to using git
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:
- A better YAML overview
- Tool for testing yaml config file
- Generate random passwords
- Python secrets module
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:
- How to install VS Code
- VS Code
- Python in VSCode
- Version control in VS Code
- Git in VS Code
- VS Code crash course
- Padding a string with zeros
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:
- Python module search paths (the -m option)
- The package setup.py file
- Command line arguments for Python programs
- Why we need a module named __main__ in the package directory
- Install Python packages hosted on Github
- References in GitHub
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.