I needed to parse the routing tables, therefore I needed to parse the command route which gives an output similar to something like this.
To get the output of the command we will use subprocess. So our python code will look like this.
But how to create a nice datastructure to hold routes ? The answer is namedtuple.
The output is.
The flexibility of python never ceases to amaze me, and I am always finding hidden gems and quicker ways to do things.