Talk Python to Me

Recently I have started learning Python. Is it because the sky is falling? Have I handed my CCIE and CCDE plaque back to Chuck Robbins? Not yet…


People that know me know that I have a big hunger for learning things. I’ve been on the networking side for 10 years now, and I decided that I wanted to learn coding to be able to interact better with developers and system administrators. If I can understand their challenges, then I can use that as input into my designs in my roles as a network architect. The networking industry is changing, and we need to broaden our skill set. Does that mean we won’t need experts in the future? No. Does that mean everyone has to become a programmer? No. Learning to code, however, brings a lot of benefits and can help set you apart from the competition when applying for jobs.


So why should someone learn Python?


  • It’s easy. Python is a lot easier to code in than many languages. I never really enjoyed coding before because I found it complex and I didn’t get past the initial barrier to become comfortable with coding. With Python, the learning curve is much better and the code is more readable due to how it uses indentation.

  • It helps you think programmatically. Learning Python has brought me back to my university days where I had to do a lot of programmatic thinking. To give you an example, I have used a Google class to learn Python, and it has mini scenarios or challenges like the following one:

    # B. front_x
    # Given a list of strings, return a list with the strings
    # in sorted order, except group all the strings that begin with 'x' first.
    # e.g. ['mix', 'xyz', 'apple', 'xanadu', 'aardvark'] yields
    # ['xanadu', 'xyz', 'aardvark', 'apple', 'mix']
    # Hint: this can be done by making 2 lists and sorting each of them
    # before combining them.

    This kind of thinking about how to break tasks down into smaller components is very useful also for a network engineer. It’s a very good skill to have when troubleshooting networks as well as building them. The task is solved with the code below:


def front_x(words):
  x_list = []
  other_list = []
  for word in words:
      if word.startswith('x'):
  return sorted(x_list) + sorted(other_list)

First a function is defined with the def front_x where a list of words is input into the function. Two new lists are created and are empty at the beginning. A for loop is then used to iterate through the list and find words starting with “x” and inserting them into the x_list. Words that do not start with “x” are inserted into another list. The result is then returned by combining the two lists.

  • It helps you study more efficiently for certifications. When studying for a certification, you will most likely have to do labs. Often some form of base topology and base configuration is used, and then each lab has unique configuration. By learning to code you can automate things like building the base topology and the base configuration. It’s also useful for things like building logical networks and advertising them into BGP. It’s tedious to create the configuration for 100 loopbacks and advertise them into BGP, but it can easily be done in Python with code, such as in the example below:


for x in range(101):
    print "interface loopback" + str(x)
    print "ip address 1.1." + str(x) + ".1"
    print "!"
print "router bgp 65000"
print "address-family ipv4 unicast"
for x in range(101):
    print "network 1.1." +str(x) + ".0 mask"


  • It can be used to automate. Before you reach the level of automation, you must first understand how all the pieces fit together. You can’t automate what you don’t know. This goes back to my point that we still need people with expertise in something. You can start automating simple tasks like provisioning VLANs. Maybe that is something that takes a lot of time today when that time could be better spent on improving the network or learning new skills.


  • It’s fun. Coding is fun and there are amazing sites out there that will help you learn to code, such as CheckIO ( where you solve puzzles and play games while learning how to code. How cool is that?! There are several other similar sites, and the Python community is really good, so there is definitely no issue in finding resources to learn how to code in Python.


I hope I’ve inspired you to start coding. I know my code above might not be the prettiest, but it works and it’s more important to just start coding than being worried if it’s the most efficient code or not. See you around people!




Note from Jennifer (Community Manager):

Earlier this year, Cisco Learning Network Premium released an introductory ten-part training video series on Python, one of the most popular programming languages in use today. To find out more about this series, check out Karlo's blog: Introduction to Python Programming