How to start python: Basic Tooling in Python

When we are talking about how to start python we must understand the basic tools that will help you in writing better code debugging and dependency management.

How to start python: Basic Tooling in Python

How to start python projects.

To start any project it is always recommended to create the project in its own environment. This means that anything that is installed for python at the global level will not affect this env and vice versa.

VirutalENV:

Install virtualenv

sudo apt-get install virtualenv

After installation activate it.

virtualenv env_name -m python3

This will create an env for python 3 and you can start working inside it. Keep in mind that you have to activate the env before running your code to make it work.

Activate env:

sourve env_name/bin/activate

Now you can install any packages that you want to use in your python program.

Deactivate env:

deactivate

Pep8 formatting.

Pep8 is the formatting style that defines how you should format your python program. How you should name your variables and more such conventions. Pep8 is highly recommended for anyone who wants to work with the opensource community.

Dependency Management

For dependency management in python, we use pip. It is used for installing packages. You can have a file naming requirements.txt which will have all the packages that you need to install along with the version that you want to install.

HOW TO INSTALL PYTHON PACKAGE:
pip install package_name
HOW TO INSTALL USING REQUIREMENTS.TXT
pip install -r requirements.txt

Debugger

Well according to me python debugger is best for anyone who is starting. Now how to use it is as below.

Where ever you want to stop the execution of code and see the values or variables or execute whatever you want. You can use the below lines.

import pdb
pdb.set_trace()

This will stop the execution of the program and give you control of the program.

Editor?

Pycharm is very good for python but if you are a power user of sublime that will be awesome.

Read more about python below

Python Tutorials

If you like the article please share and subscribe. You can also join our Facebook group:https://www.facebook.com/groups/327836414579633/ and Linkedin group:https://www.linkedin.com/groups/10441297/


Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.