Learning paths › Automation › Tuples, sets and dictionaries for device records
Tuples, sets and dictionaries for device records
Choosing the container a device record belongs in: a tuple for a fixed group, sets for distinct values and for comparing two collections of addresses, and dictionaries read without risking a KeyError and copied without sharing their nesting — then functions in detail, arguments bound by position or name, a parameter made optional, a value returned rather than printed, any number of positional or named arguments accepted, the LEGB name rule, and what a mutable argument shares. Explanation and checks; three written exercises.
Lessons
- Split text into fields and join it back
- Pull addresses out of interface output
- Build a fixed group of values
- Concatenate, slice and test tuple membership
- Query a tuple with index and count
- Choose the right one for a device record
- Keep only distinct values
- Add and remove set members safely
- Compare two sets of addresses
- Freeze a set so it cannot change
- Describe a device as key-value pairs
- Read a key without risking KeyError
- Copy a dictionary without sharing its nesting
- Iterate keys, values and items
- Build a mapping in one expression
- Name an operation and call it again
- Bind arguments by position or by name
- Make a parameter optional
- Return a value instead of printing it
- Accept any number of positional arguments
- Accept any number of named arguments
- Resolve a name with the LEGB rule
- Understand what a mutable argument shares
- Write a one-expression function inline
More in Automation
- First scripts that configure devices
- NAPALM: structured data across vendors
- Concurrency, and the Python types device output returns
- Parsing show output and testing conditions
- Readable code, branching and loops
- Build the workstation and the toolchain
- Files, CSV, JSON and pickle
- Paramiko: SSH to devices from Python
- Netmiko at fleet scale
- Exceptions and your first classes
- Plan and build the automation lab
- Files, formatting and regular expressions
- Addresses, functions, modules and classes
- CSV inventories, logging and scheduling
- Netmiko, SCP and structured parsing
- Agents, async and model-driven workflows
- NETCONF, YANG and RESTCONF
- NX-API, pyATS and Genie
- A small GenAI app, end to end
- macOS, Linux and the virtual lab
- Agile delivery and Python fundamentals
- REST APIs, authentication and requests
- Flask, Docker and Jenkins
- Managing a router with NETCONF and RESTCONF
- Ansible: inventory, ad-hoc commands and first playbooks
- Roles and zero-touch provisioning for Linux switches
- Installing the controller and applying a project
- Setting up Python 3
- The Ansible lab and the controller
- Vault, variables and config changes
- Parsing output and knowing which variable wins
- Jinja filters and PAN-OS automation
- Loops, callbacks, strategy and run control
- Roles, imports and writing your own module
- Running playbooks from AWX