Network Automation using Python
We are starting with series of posts which will help you to automate your networking tasks using Python. This is a step by step guide which will show how to install Python and start your first program. You do not require any programming skill to start with automation. Please keep watching on upcoming posts to understand better.
What is Python
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is also available under the GNU General Public License (GPL). This tutorial gives understanding how to install python one Windows machine and make it ready for Network Automation programming. Here in this post I will be covering only essential parts to start with Python so that we can continue with the network automation things in the coming posts. Please follow https://www.tutorialspoint.com/python/index.htm for more on basic/advanced python training.
Read more
Download Python
Download python from following link. You can either download 2.7 version or latest 3.6 version.Here we are showing 3.6 version since this is the latest and our all automation scripts are based on 3.6 version.
https://www.python.org/downloads/
Install Python.
Double click on the downloaded exe file and proceed with next until it gets installed.Leave all values default.
——————- advertisements ——————-
———————————————————-
Accessing Python.
Once it is installed, it will be available in program list.
Click on Start-All Programs-Python 3.6 and click on IDLE .IDLE is the name of IDE for Python scripting .
Writing your first Program:
Once you have clicked IDLE, you will be available with following window.
To start with new program , click file -> New file. This will open new window where you can start coding.Here we will write a program to print Hello World . You can directly start coding from first line on wards as python does not require any ‘main’ or ‘initialization’ statements for simple programs.
——————- advertisements ——————-
———————————————————-
Save the program
Click file and Save to save the program . The program will be saving with .py extension
Run the program.
Python does not require any compilation before running program as python is an interpreter program. To run the program , Select Run and click on Run Module
The result of the program will available on the first window. (Shell window)
——————- advertisements ——————-
———————————————————-
Accessing program from command line.
You can use following method to run the script which is created earlier or given by someone else. To run the program from command line, open CMD and navigate to the folder where your script has been saved .Type python and after that script file name on CMD. This will run the script and provide the out put on command prompt.
Hope you got the idea how to install Python and run your first program. Please click here for more posts from this series. Please use the comments section in case if you have any queries.
Reference:
https://www.tutorialspoint.com/python
https://www.python.org/