Python Hunt Series - Scaffolding
Hi, this is first post in the series " Python Hunt " . To start with, I will talk about setting up environment to work on Python.
At first place we need to install Python. Python comes in 2 major versions, python 2.x and 3.x. If you are starting fresh, I would suggest to go for python 3.
You can read about the difference between python 2 and python 3 from below link
Windows users can install Python from Python official site
Note : path (Environment variable ) should be altered to include Python binary
Linux users will be having Python by default
To check whether Python is installed already, open terminal and type
Python -V {or} Python --version
You will see the version of Python if installed already.
If not, then download the latest source from python official website and install
tar -xvf [tar file name]
cd to the new folder generated
make
sudo make install
Python -V {or} Python --version
Once Python is installed successfully, we need to select appropriate editor to start working.
Explore about Atom IDE and install it. We need to install few add on's in Atom and Python for highlighting the errors and auto complete options to be available
Before getting into that lets see how to add a package in python. There are lot of 3 d party python packages available which will enhance the functionalities for programming. For example if you want to work on isolated environment, you need to install virtualenv package from below address
https://pypi.python.org/pypi/virtualenv/13.1.2
Note: pypi - python package index is the repository for python packages
pip comes as a handy solution in installing python packages. Just provide the below command to install the package. pip will pick the source from pypi
pip install <package name>
Note: python 2.x doesn't include pip by default. pip needs to be installed separately using setup file
Now lets get back to the add on's which will make the editor effective.
Install flake8 through pip in the python environment. Once done install linter and linter-flake8 in atom
In Atom, you need to go to packages tab -> settings view -> packages
then search for the package name and install it. Alternatively you can also use atom package manager - apm
These packages will help in highlighting the standards while coding. Once we have these add on's in place. Open atom and start typing
type " def " you will see auto populating options. select the function option from it
You should be seeing warning. This is because our script is not according to PEP8 standard.There should be 2 line space between functions and 2 function cannot have the same name.Now add the needed space, change the function name and save. The warning should vanish.
Yup, we have installed python and a proper IDE is set. Let's start coding...
Next post in the series - Isolated Environment
Cheers!
Next post in the series - Isolated Environment
Cheers!
No comments:
Post a Comment