Updated September 10th, 2022
You do NOT need to know anything about python to use the scripts. This is just like you don't have to know how to program to run "show interface g1/0/1". You simply download the script and execute it.
I found this tweet that has a curated list of python resources:
Why You Should Learn Python
A lot of the tasks that network engineers perform are repetitive, mind-numbing, and error-prone. With a little python skill, you can automate these tasks and spend the time you save on more productive tasks, like learning more python.As networking moves away from the CLI and into software-defined networking (SDN) you will need to have some dev skills. Cisco has a three-part video on how the network engineer's job is changing. You will need to register with Cisco Devnet to watch it but you should have a Devnet account if you going down this path:
Lesson 1: The Network Engineer of Old
If you have never used Python at all, this blog is the place to get started!
First, to install python, head over to the Python download page - Download Python
Follow the instructions to install python on your OS of choice.
Tools
There isn't much needed to use Python other than python itself but like most things, life is easier with some tools.Integrated Development Environment (IDE)
IDEs are tools that allow you to write and debug code. Once you start writing scripts that are more than a few lines long you will want to use an IDE.Thonny - Python IDE for beginners. A free Integrated Development Environment. This tool is great for learning. It lets you step through a script and see exactly what is happening.
MU - a simple Python editor for beginner programmers. This one is really nice. It's cross-platform and has support for Linux, Mac, Windows, and Raspian. What separates it from the other tools listed here is the support for small devices like Adafruit and Micro:bit. Here is a screenshot of MU starting up:
Microsoft Visual Studio Code - A free open source IDE from Microsoft. VSCode has turned into an amazing development environment and can be used for any size project. It has an integrated debugger that looks just like the Powershell ISE tool. It supports almost every programming language, not just python. The open-source version of PowerShell is fully supported which is great. I can use one tool and create Python and PowerShell scripts.
There is a Visual Studio Marketplace with thousands of plugins, similar to the Chrome store or Firefox store. Extensions for the Visual Studio family of products
I have more detail on my macOS blog. Once you have VScode installed it works the same on Windows, Mac, and Linux so the blog is useful regardless of what OS you use. My VSCode install blog
Code Editor
You can definitely use VSCode as your editor. It has about every feature that you could want. But I have been using Sublime text since before VSCode came out and old habits die hard! If you are on Ubuntu 22.04 you can install Gnome Text Editor (I know, really, really stupid name) and it works great for quick editing.
Sublime text - Sublime is a text editor that is optimized for programming. It has a huge community around it and thousands of plugins. It's $75.00 but the license lets you run it on as many machines as you own. I bought it and installed it on my Linux, Windows, and Mac laptops. It has a tabbed interface like notepad++ which I like. You can also split the screen and open two files side by side. This is useful because you can have your script on one side and the data file on the other. Realpython.com sells a great tutorial that walks you through installing Sublime text optimized for Python. It includes video and text for Mac, Linux, and Windows. This tutorial is well worth the cost and has improved my productivity in Sublime.
In the next section, I discuss revision control with Git. Sublime text has several plugins that integrate Git into your workflow. One I really like is Git Gutter. It puts a + sign next to lines that have changed, then you can revert easily if the change didn’t work.
Your Shortcut to a Professional Python Development Setup
Both of these sites have thousands of python tools. If you have git installed on your computer all you have to do to use them is "git clone <repository>". For example, to install the ARP sorting tool I wrote, you simply go to ARP-Sort and click the "Code" button. It will display the URL for the project. Click the copy button, type “git clone” and paste the URL you copied into the terminal, then press enter:
Your Shortcut to a Professional Python Development Setup
Revision Control
Git - A revision control system. It's useful once you start writing scripts large enough to have bugs or future enhancements. Even if you don't program in python it's worth installing git because of github.com and gitlab.com.Both of these sites have thousands of python tools. If you have git installed on your computer all you have to do to use them is "git clone <repository>". For example, to install the ARP sorting tool I wrote, you simply go to ARP-Sort and click the "Code" button. It will display the URL for the project. Click the copy button, type “git clone” and paste the URL you copied into the terminal, then press enter:
git clone https://github.com/rikosintie/ARP-Sort.git
This downloads the project and unzips it into the folder ARP-Sort.
Install git from https://git-scm.com/
Pro Git book - A free online book on git
Learn Git Command with Practical Examples on Linux – Part 1
Cisco DevNet GitHub Repo - Great resources on setting up your laptop with Python, Git, Postman, etc.
Git and GitHub for Beginners - Crash Course - A really good video on git.
Real python did a blog on the best Youtube channels for python
The Ultimate List of Python YouTube Channels
Subscribe to HackerSploit on Youtube and there is a complete series on Python. He uses 2.7 but it is still a good tutorial. They are really basic but I find Alexis entertaining.
Python For Ethical Hacking - #1 - Introduction & Python Modules
Telusko Python for Beginners
Python Tutorial - Python for Beginners [Full Course] - Mosh
Learn Python - Full Course for Beginners [Tutorial] Free Code Camp
Videos from Udemy.com
Udemy has inexpensive video training for Python, Linux, and a lot of other applications. These are on sale all the time for $9.99- Python Network Programming - Part 1: Build 7 Python Apps
- Complete Python Bootcamp: Go from zero to hero in Python 3
- 100 Days of Code - The Complete Python Pro Bootcamp for 2021
Videos on Youtube
I find that I learn better when using books and websites but sometimes it's nice to watch a video.Real python did a blog on the best Youtube channels for python
The Ultimate List of Python YouTube Channels
Subscribe to HackerSploit on Youtube and there is a complete series on Python. He uses 2.7 but it is still a good tutorial. They are really basic but I find Alexis entertaining.
Python For Ethical Hacking - #1 - Introduction & Python Modules
Telusko Python for Beginners
Python Tutorial - Python for Beginners [Full Course] - Mosh
Learn Python - Full Course for Beginners [Tutorial] Free Code Camp
Writing Pythonic Code - A Tweet thread by @Bascodes. He is worth following.
Corey Shafer Videos
I recommend that you subscribe to this channel. Here are four of his videos that I found very useful
Requests Tutorial - The requests library is used to pull data down from webservers
JSON Tutorial - Java Script Object Notation is a common data format used by APIs
Sorting Tutorial - Sorting routines for lists and dictionaries
List Comprehensions - Working with list comprehensions
e-books from Amazon
I love the Kindle app on my laptop, phone and iPad. If I get stuck in a long line I just open it up and do some studying! These were all under $5. You can go to Amazon, set filter to Kindle store and enter "python programming free book" and find a lot of free books.- Learn Python in One Day and Learn It Well Python for Beginners with Hands-on Project The only book you need to start coding in Python immediately By Jamie Chan
- Python Tips and Tricks: Learn the Best Tips and Tricks to Get The Most out of Python NOW! Jones, Daniel
- The Fundamentals Of Python Programming: A Complete Beginners Guide To Python Mastery.
- Python Programming Tips and Tricks: The Ultimate Cheat Sheet for Python Programming. 20+ Tips and Tricks to Make Your Life Easier and More Efficient
- Automate the Boring Stuff with Python: Practical Programming for Total Beginners
Websites
There are so many python websites it would be impossible to list them all, here are a few I have found very useful:
Getting Started
- realpython.com - A great site for learning python. You can sign up for a weekly tip that is emailed. They also have a lot of tutorials that are very good.
- Real Python Your Guide to the Python print() Function - Includes using f strings. Very good tutorial.
- realpython.com/start-here/ - This page has a lot of getting started tips.
- realpython.com/products/real-python-course/#course-packages - This is a $60 course that looks pretty comprehensive. I didn't take it but everything else from real python has been good.
- Tutorials Point - Python 3 tutorials
- Python Practice website - A free site with practice problems and solutions.
- Python for Beginners
- Geeks for Geeks - A computer science portal for geeks. Search for python.
- What I did to learn Python
- Finxter Python Courses - This site has training and if you register free cheat sheets.
- A Quick Tour of Python Language Syntax - by Jake VanderPlas. Much more on this site.
- String Manipulation and Regular Expressions- by Jake VanderPlas. Much more on this site.
- Stack Overflow - A site dedicated to programming questions
- 17 Killer GitHub Repos You Need to Save Right Now! - Not 100% python, but a lot of resources.
General Tips
- Grepper - An awesome collection of code. They have a Chrome extension that captures code searches and displays ranked results. Pretty cool.
- Python 3 Module of the Week - A site with a ton of examples of how to do things in python. There is a good tutorial on the IP Address libraries.
- Python Built In Functions
- Understanding all of Python, through its builtins
- Python parentheses primer
- Python, argparse, and command line arguments
- Python Utilities
- Reverse Strings in Python: reversed(), Slicing, and More
- Python Regex Cheatsheet
- Data Science Cheat Sheet - Python Regular Expressions
- ActiveState Code Recipes - Welcome to the ActiveState code recipes repo! We have migrated all of the great content from code.activestate.com to its new forever-home here at GitHub. This makes it easier for everyone to submit new recipes, contribute code and integrate all the great information into their own projects.
- 10 Python Scripts to Automate Your Daily Problems
- Documenting Python Code and Projects
Jinja Templates
- Template Designer Documentation - Jinja is a templating language that you can use with Python
- Python for Network Engineers Jinja tutorial
- Tips and Tricks
- Getting started with Jinja2
- List of Control Structures
- jinja2-live-parser
- Pallet Projects Jinja Tutorial
- Jinja2 configuration templates - Python for Network Engineers
Network Engineering
- Hubbard On Networking GitHub Repo
- Python for Network Engineers - The name says it all! Kirk Byers wrote the netmiko python libray to automate network device operations.
- Netmiko Github - The github repository for netmiko python library
- Cisco Devnet site - The learning labs part of DevNet. Great training videos. You can use a Cisco account or create a free account.
- Cisco DevNet Evolving Technologies Study Guide - Nick Russo's guide
- Batfish - An Open Source network configuration analysis tool
- Cisco Config Analysis Tool - A python tool that takes a Cisco running config and compares it to the Cisco best practices guide.
- Primer on Jinja Templating - Jinja templates can be used to create config files from Excel data.
- Welcome to the Postman docs! - Postman is a tool used to interact with RESTful API.
- Reading and Writing CSV Files in Python
- Getting started with TextFSM
- Example of using Jinja - Python for Network Engineers
Debugging
- Python 3 - Exceptions Handling
- Python Try Except Else Finally error handling
- Tips for debugging with print()
Web Development
- Twitter University is Free! - You can learn 98% of web development by reading these 10 threads
- Awesome Web Development Resources - Not specifically Python but has a lot of great resources
- Create Web Apps with Python Flask
Style guides
Python is a structured language that uses white space as part of the structure. But you can still create ugly code. The official Python style guide is part of the Python Enhancement Proposals (PEPs) which are documents that provide guidance and spell out best practices for how Python code should be organized, packaged, released, deprecated, and so on. PEP8 is a popular standard for styling Python code and is extensively used in the developer community.
- PEP 8 – Style Guide for Python Code - The official style guide for Python
- How to Write Beautiful Python Code With PEP 8 - Real Python PEP8 Tutorial
- Documenting Python Code: A Complete Guide
Python Virtual Environments
As you start learning and creating more python tools you will want to start using virtual environments. These two blogs will teach you what you need to know. There are a lot more blogs available on the Internet.
Podcasts
You probably won't learn much coding from a podcast but these are very interesting to listen to. I find a lot of good links in the show notes. For example, I learned about Thonny, MU, and Visual Studio Code from podcasts.Talk Python To Me - A good podcast that covers a lot of topics. There will be one called "Teaching Python to network engineers" in August, 2018!
Podcast.__init__ - A podcast about Python and the people who make it great. Hosted by Tobias Macey.
Python Bytes - Python Bytes podcast delivers headlines directly to your earbuds. If you want to stay up on the Python developer news but don’t have time to scour Reddit, Twitter, and other news sources, just subscribe and you’ll get the best picks delivered weekly.
Keywords In Python
There are 33 keywords that should never be used as a variable, function name, class, object, or as any other identifiers in your programs.false
True
finally
class
for
continue
none
return
lambda
try
is
def
from
nonlocal
while
and
not
global
del
with
as
elif
if
or
yield
break
import
except
pass
assert
else
raise
in
Libraries
Pint - Pint is a Python package to define, operate and manipulate physical quantities
Nice Blog!!
ReplyDeleteLearn Python Online Course
Python Online Course
Hi, I read your whole blog. This is very nice. Good to know about the .net and is very demanding in future. We are also providing various Python Training & Certification Courses, anyone interested can Python Training for making their career in this field.
ReplyDelete