Why Python is important for Network Engineers

Brief article explaining why Network Engineers could benefit from learning Python, and how best to get started.

What is Python?

Python is a multi-purpose programming language, used for scripting instructions that computers, machines, and computing devices can follow to perform specific tasks. In the last 30 years, Python has become one of the most popular and widely adopted programming languages. Why? Because Python is:

  • Simple – Python has a clear and simple syntax, that compared with other languages makes it easier to learn. This simplicity also means developers can writer few lines of code to achieve the same goal.
  • Adaptable – Python is described as a general-purpose programming language because it can be used to programme a wide variety of tasks, from calculating complex mathematics in Data Science to building simple websites.
  • Open Source – Python has a thriving global community of users who offer support, help answering questions and contribute to developing reusable Python libraries. This means these is always someone to help solve your problem.
  • Free and reliable – A lot of effort goes into developing and managing new code releases, updates, and bug fixes to ensure reliability is maintained as the new technology landscape evolves. This is all thanks to the generous work of the team at The Python Software Foundation (PSF).
Data Source: TIOBE Index – The TIOBE index is an indicator of the popularity of programming languages.

History of Python?

Python was invented by Dutch programmer Guido van Rossum, and officially released in 1991. Whilst working for the national research institute for mathematics and computer science in The Netherlands, he encountered limitations using the ABC programming language for systems administration. His team needed a scripting language that was simpler than C and more flexible than alternatives at the time: Pearl, TCL, and Modula-3. Over the Christmas holidays, he decided to design a new language, that borrowed many of the good features from ABC and improved on the limitations. Python was born, curiously named after “Monty Python’s Flying Circus.”

Network Engineer learning how to code

Why learn Python?

As the number of data-hungry network devices continues to grow, the job of a Network Engineer is becoming increasingly complex. More devices, means more connections, more configuration, administration, troubleshooting, updating, documentation etc. Tasks and responsibilities are piling up, but work hours remain the same. Python allows Network Engineers to write scripts that automate complex network configuration tasks and processes. This saves time and reduces human error in a way that is highly scalable and easily repeatable.

Cisco and Juniper have both selected Python as the network programming language of choice. Cisco is teaching Python as part of its DevNet programme, and Juniper developed a Python library called PyEZ, for easy automation of its Junos devices, for example. Lots of network automation tools are written in Python. But why Python? Well, compared with other programming languages, Python has a simpler syntax, more intuitive vocabulary, and shallower learning curve. Just as water takes path of least resistance, network engineers (who did not start out as programmers) are looking for the friendliest bridge to cross from the familiar world of hardware, over to the scary world of software development.

What network engineering tasks can I automate with Python?

The reason Python is so popular for network automation is because it is so flexible. You can use Python to select any network interface, IP address, protocol, TCP/IP socket etc. and build literally any automation use-case. Your imagination really is the only limitation! Additionally, new networking equipment includes Application Programming Interfaces (APIs), which specifically allow hardware devices to be configured using software code like Python.

Here’s a brief list of use cases where Python can save network engineers time:

  • Automatically detect new network devices
  • Backup all network devices and configurations
  • Take inventory of network hardware
  • Manage End of Life milestone dates
  • Update firmware on routers/switches/firewalls
  • Automatically update and generate documentation
Example of a Python script interfacing with Cisco routers

What are the alternatives to Python?

  • AnsibleAnsible is an integrated automation platform that uses Playbooks to record and execute automation workflows. Ansible Playbooks are written in YAML programming language, but you do not need to know YAML to use Ansible, making it very user friendly. Ansible is widely used by DevOps engineers to automate, orchestrate, and configure IT infrastructure.
  • Yet Another Next Generation (YANG)YANG is a data modelling language that defines data sent over network management protocols such as the NETCONF. YANG is the main language for programming Cisco’s Network Services Orchestrator (NSO) network automation tool.
  • Stylesheet Language Alternative syntaX (SLAX)SLAX is a programming language for Juniper users to write Junos scripts.

Will Python take my job?

Unlikely. Network Engineering is a highly-skilled profession. As network capacity and complexity increase, so will demand for network engineers. The main business case for Network Automation is relieving network engineers from low-value, repetitive, admin-heavy tasks, so they can focus on high-value tasks like designing, building, and maintaining better networks. Recent network outages (Facebook, Oct 2021) or Cyber Attacks (SolarWinds, 2020) have highlighted just how critical network infrastructure is to technology dependent operations of modern businesses.

Network engineers should view the adoption of Python by their industry as an opportunity! Those with the foresight and initiative to learn Python early, can separate themselves from the crowd and place themselves in the way of the most exciting job offers and highest salaries on the market. The networking industry is known for its modest pace of evolution; use this to your advantage. Learn Python now, so when the demand for Python heats up, you already have the skills and experience to take advantage of new opportunities.

How to I get started in Python?

Learn Python, the way that works for you!

This depends on how you learn. For some people, the first step may be reading a book to understand the theory, then applying it. Some benefit from the structure and human interaction of a course. Others like to dive-in headfirst and figure it out as you go along. Learning by doing, so to speak. At any rate, here are some resources to start you on the right path:

Books:

  • Network Programmability and Automation: Skills for the Next-Generation Network Engineer – Jason Edelman – Jason founded Network to Code, one of the leading Network Automation firms globally.
  • Mastering Python Networking: Your One-stop Solution to Using Python for Network Automation, Programmability, and DevOps – Eric Chou – A bestselling guide to mastering Python Networking.
  • Automate Your Network: Introducing the Modern Approach to Enterprise Network Management – John W. Capobianco – Provides fantastic background to why and how enterprises are implementing Network Automation.
  • Automate the Boring Stuff with Python: Practical Programming for Total Beginners – Al Sweigart – More generalist book focusing on how Python can be used to automate anything!

Courses:

By doing: