In this post, I will explain you why the good practice in Python programs is to carefully import only what is necessary to run your program. Let’s start with an example. Sometimes, I feel lazy and use:

from toto import *

This is a bad idea, as sometimes the name of the things that you import will conflict with the name of other things in your programs. And this can be a nightmare to debug. So, try not to be lazy and rather define explicitly what you want to import with:

import toto

or

from toto import titi, tata


Leave a Reply

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