Two Tools That Will Boost Your Python Scripts

Two Tools That Will Boost Your Python Scripts

if __name__ == ‘main’ and argparse (+ bonus) .Two tools that will boost your Python scripts.

These two tools that you will read here are going to increase exponentially the usability of your python scripts.

If you have read a bunch of code or you’re developing some big project and you need to do more than one script you need to know what if name== ‘main’ is. A way to write your functions only one time and use it in all of your scripts.

And if you are trying to make a program than anybody can execute the argparse library will make it efficiently for you. A way to introduce help and different arguments to your code.

if name == ‘main’:

What’s about the name variable? When the python interpreter read a source file it first defines a few special variables. In this case, name is one of them.

And the main? You’ll know that your code may have different parts. The functions you’ve defined are one of them and the other one is the main part. Usually the main is where you use your functions in order to make your code accomplish what’s been designed for. As you know well, it’s not obligated to use functions but if you need to do a concrete thing more than one time it’s very desirable to encapsulate it inside a function with a self-explanatory name. And it’s a good way to work to organize the structure of your code with all the functions above the main part. Now you’ll understand why. It will make your work easier and more readable for some stranger. And that’s always a good thing. Who knows if the stranger could be you in just a couple of months after writing the code.

python programming data-science

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Data Science With Python Training | Python Data Science Course | Intellipaat

🔵 Intellipaat Data Science with Python course: https://intellipaat.com/python-for-data-science-training/In this Data Science With Python Training video, you...

Must-Know Data Science Libraries in Python

In this tutorial, we'll learn Must-Know Data Science Libraries in Python. Python is the most widespread and popular programming language in data science, software development, and related fields. The simplicity of…

How To Build A Data Science Career In 2021

In Conversation With Dr Suman Sanyal, NIIT University,he shares his insights on how universities can contribute to this highly promising sector and what aspirants can do to build a successful data science career.

Data Science with Python Certification Training in Chennai

Enroll in our Data Science with Python training in Chennai. Best Data Science with Python Training courses in Chennai for 100% Job Placements Support.

Python for Data Science | Data Science With Python | Python Data Science Tutorial

🔥Intellipaat Python for Data Science Course: https://intellipaat.com/python-for-data-science-training/In this python for data science video you will learn e...