Python for Network Engineers: From show Commands to Automation

RRouting & Automation FacultyPublished Updated 5 min read
Python for Network Engineers: From show Commands to Automation

Network engineers don't need computer-science-level Python — they need about 20% of the language plus four libraries: Netmiko for SSH automation, TextFSM for parsing show-command output, Nornir for running tasks across an inventory, and requests for REST APIs like RESTCONF. Starting with a script that backs up device configs, an engineer can reach useful automation within four to six weeks of part-time practice.

Most Python-for-networking advice fails in one of two ways: it either teaches the whole language as if you were becoming a software developer, or it hands you copy-paste scripts you can't modify when something breaks. The useful middle path is narrow and well-trodden — a small slice of Python, four libraries, and a sequence of projects that each solve a problem you already have. Here is that path, as we teach it to working network engineers.

The 20% of Python you actually need

Before touching a network library, be comfortable with: variables and f-strings (device names, IP addresses, building commands), lists and dictionaries (inventories and structured data — this is the big one), for loops (the same task across fifty devices), if/else conditions, functions with parameters, reading and writing files, and try/except for the reality that some device is always unreachable. That is genuinely all. Classes, generators and async can wait until you need them, which for most engineers is months away — if ever.

Four libraries, in order

Netmiko — SSH that speaks network

Netmiko wraps SSH with device-aware handling for Cisco IOS, IOS XE, NX-OS, Junos, Arista EOS and dozens of other platforms. Connect, send commands, collect output — your first real script is ten lines. This is where automation stops being abstract: the day you back up thirty configs in forty seconds, the point makes itself.

TextFSM and ntc-templates — turning text into data

The output of 'show ip interface brief' is text formatted for human eyes. TextFSM, with the community ntc-templates library, parses hundreds of common show commands into lists of dictionaries you can filter and compare in code. Parsing is the unglamorous skill that separates engineers who automate reporting and compliance from engineers who only automate typing.

Nornir — scale with an inventory

When device lists outgrow a hard-coded Python list, Nornir gives you a proper inventory (hosts, groups, credentials), runs tasks concurrently, and collects results per device. It is pure Python — no new DSL to learn — and it is the natural bridge between "my scripts" and "our automation framework". This is also the point to put your work in Git, because scripts that change production networks deserve version control.

requests — the API door

Modern platforms — IOS XE with RESTCONF, Meraki, DNA Center/Catalyst Center, firewalls, IPAM tools — expose REST APIs, and the requests library is how Python talks to them. Learn to send authenticated GET and POST calls, read JSON responses into dictionaries, and handle pagination and timeouts, and the entire API ecosystem opens up with the same handful of patterns repeated everywhere.

A project ladder that keeps you honest

  1. Config backup: Netmiko plus file handling; dated backups for every device in a list.
  2. Compliance check: parse configs to verify NTP, SNMP and ACL standards; print what deviates.
  3. Pre/post change snapshot: capture routing tables and interface states before and after a change window, and diff them — the script that makes change managers love you.
  4. Bulk configuration with review: generate configs from a Jinja2 template and an inventory spreadsheet; push only after a human approves the rendered output.
  5. API integration: pull interface utilisation over RESTCONF into a small report, or reconcile your IPAM against reality.

Each project is roughly a week of evenings. By the fifth you will have a portfolio that means something in interviews — and colleagues asking to use your tools, which is how automation roles quietly begin. Resist the urge to skip steps: engineers who jump straight to the API project without the parsing work behind them tend to produce automation they cannot debug, and debugging is where the job actually lives.

Set up a lab you cannot break production with

Never learn automation against devices that carry traffic. A safe practice setup costs nothing: Python 3 in a virtual environment (venv keeps library versions per project — a habit worth forming on day one), Git for every script from the start, and something to automate against. Cisco Modeling Labs or EVE-NG give you a topology on your laptop; Cisco's free hosted sandboxes offer always-on IOS XE instances reachable over the internet; and if you train with us, the Skillopia racks are available around the clock. Add a linter (ruff or flake8) early — network scripts fail in production for the same sloppy reasons any code does, and the linter teaches you faster than the outage will.

Where this leads: certifications and roles

This skill set maps directly onto Cisco's automation track — CCNA Automation (formerly DevNet Associate) at the associate level, ENAUTO as a CCNP concentration, and CCNP Automation beyond that. In the Indian market, engineers who pair CCNA-level networking with working Python routinely command offers 20–40% above CLI-only peers, and titles like network automation engineer and NetDevOps engineer are among the fastest-growing postings in Mumbai, Pune and Bengaluru.

RST Forum teaches this exact progression — Python foundations through Netmiko, Nornir and API automation — in classroom batches in Mumbai and live online, with every lab run against real routers and switches on the Skillopia platform rather than screenshots of someone else's terminal. Twenty-nine years of teaching networks (a million-plus engineers since 1997) has settled our view: engineers learn automation fastest when the device at the other end of the script is real. The first lecture of any batch is free — bring a show command you hate typing, and leave with the script that types it for you.

Frequently asked questions

How much Python do I need before automating network devices?

Roughly the first fifth of a general Python course: variables, strings, lists and dictionaries, loops, conditionals, functions, file handling and try/except. You do not need classes, decorators or async to start. Most engineers are ready for Netmiko within two to three weeks of consistent practice.

Should I learn Python or Ansible for network automation?

Both, eventually — but Python first. Ansible is faster for standard configuration pushes, while Python handles parsing, logic and API work that playbooks do badly. Engineers who know Python also debug Ansible better, because they understand what the modules are doing underneath. In job descriptions the two are usually listed together.

Will automation replace network engineers?

It replaces tasks, not engineers — specifically the repetitive CLI work that fills L1 queues. Demand is shifting toward engineers who can build and supervise that automation. The realistic risk in 2026 is not being replaced by a script; it is being outcompeted by an engineer who writes them.

What is the best first automation project?

A configuration backup script: connect to a list of devices with Netmiko, run 'show running-config', and save each output to a dated file. It is genuinely useful from day one, teaches connections, loops, files and error handling in one project, and grows naturally into compliance checking and change automation.

Does Python knowledge count toward Cisco certifications?

Directly. The CCNA Automation track (formerly DevNet Associate) is substantially Python, APIs and data formats, and the current CCNA 200-301 blueprint includes automation and programmability concepts. The skills in this article map straight onto those exams — and onto the ENAUTO concentration at the CCNP level.

R

Written by

Routing & Automation Faculty

CCIE R&S / CCNP Automation · network automation practice lead

The routing, switching and network-automation teaching team — placeholder profile, rename to a named trainer in the CMS before launch.

Learn this hands-on

  • Software Development

    Python Programming

    Syntax to scripts that do real work - files, APIs, data and automation - and the base for RST's Data Analysis, DevOps and AI tracks.

    • 80 hrs
    • 18 labs
    • Beginner
    Course fee₹15,000
  • Cisco Certifications

    CCNA Automation (200-901 CCNAAUTO)

    Embark the journey of becoming a network programmer and an automation expert with the Cisco Automation course. CCNA Automation (200-901 CCNAAUTO) at RST Forum is a 120-hour instructor-led course (lectures plus hands-on lab practice) for beginners. Classroom batches run at our Mumbai campus and the same batch streams live-online across India; the fee is ₹15,000.

    • 120 hrs
    • 19 labs
    • Beginner
    Course fee₹15,000
  • Cisco Certifications

    Automating and Programming Cisco Enterprise Solutions (ENAUTO)

    Automate the future of networking: Enroll in the ENAUTO course and embrace the power of network automation. Automating and Programming Cisco Enterprise Solutions (ENAUTO) at RST Forum is a 120-hour instructor-led course (lectures plus hands-on lab practice) at advanced level. Classroom batches run at our Mumbai campus and the same batch streams live-online across India; the fee is ₹25,000.

    • 120 hrs
    • 19 labs
    • Advanced
    Course fee₹25,000

Reading is the start. The lab rack is the difference.

Reserve a seat on any batch - classroom in Mumbai or live online. Sit in on the opening session, meet the trainer and see the Skillopia labs before you commit.