Author Archive: admin
Changing Data Structure Format

This is going to be a example how to create a new dictionary out of an output : 1st the dictionary that we are going to change with only specific items with different key names : from pprint import pprint…
Read more
Handling Complex Data Structures

To work with data structure you can drill down to which information you need using these commands to peel it layer by layer : 1st determine what kind of data : List : output.keys() type(output) len(output) Then to see the…
Read more
Importing Libraries

To import a library in python you need to specify it in the beginning of the script file : import “library” example pprint is a library for an easy reading output. to see where that library is install : “library”.__file__…
Read more
Virtual Environment

Hey Ben ! : See below the install Linux and Windows for me details how to : —— LINUX —– Install : apt-get update apt install python3-virtualenv cd ~ cd VENV virtualenv virtualenv-3.6 -p /usr/bin/python36 “virtual env name” ll or…
Read more
Python Path

import sys sys.path Every time you are importing a package “netmiko” this is where it is going to look for it. to remove the default path for python : env | grep PYTH unset PYTHONPATH env | grep PYTH cat…
Read more
PIP
Complex Data Structure

When dealing with very large output data structure , and need to extract data from it : Example : Devices = { ‘sw1’: { ‘ip_addr’: ‘10.10.10.1’, ‘username’: ‘admin’, ‘password’: ‘cisco’, ‘bgp_peer’: ‘10.10.20.1’, ‘10.10.30.1’, ‘10.10.40.1’}, ‘sw2’: { ‘ip_addr’: ‘10.10.10.2’, ‘username’: ‘admin’,…
Read more
JSON Basics

You can use JSON to output a dictionary so it is easier to read, personally i prefer the pprint output but as today i didn’t got a chance to see why i would use that. so to be updated soon…
Read more
YAML Basics

Example of a YAML file : List : — – 10.10.10.1 – 10.10.10.2 – 10.10.10.3 Dictionary : — Key:value device1: 10.10.10.1 device2: this is a string device3: “this can nclude special characters” device4: True or true or yes or no…
Read more