Python for Network Engineers

True and False in Python

By George El. • March 2019 • Reading time: 2 minutes

In this Post I will describe what is True and False in Python. Then how to use “all” and “any” to combine these values and finally make a function that will check if an ip address is valid. In python all numbers are True except 0, every object that is not None, every string that is not empty, every list that is not empty, every dictionary that is not empty.

Read More...

Classes in Python

By George El. • March 2019 • Reading time: 6 minutes

In this post I will explain what classes are and then I will show you how to create instance methods and class methods and what is the difference between them. Then I will also show you how to create static methods. What are classes? Classes are blueprints that represent real life objects.

Read More...

Slices in Python

By George El. • February 2019 • Reading time: 1 minute

With Slices we can take a slice (sub section) of any sequence, like lists and tuples. The syntax is slice(stop) slice(start, stop, step) but we can shorten it to nameofsequence(start:stop:step) where start - starting integer where the slicing of the object starts (optional, 0 is default) stop - integer where the slicing stops.

Read More...

How to Iterate Efficiently Through Lists Files and Dictionaries

By George El. • January 2019 • Reading time: 3 minutes

In this post I will show you how to iterate efficiently through lists, dictionaries and files in pythons if you are familiar with other languages, maybe you are used at iterating through an array/list using an index like for(var i=0; i<arr.length; i++) { print(arr[i]) } this in python is not needed as lists and dictionaries are iterables and implement the next method.

Read More...