3 Key Skills for Handling Modules in Python

Manage and use Python modules elegantly

Yang Zhou
TechToFreedom

--

In Python, a module is a file containing Python code and its name has the suffix — .py. Generally speaking, putting related classes or functions into a module and separating the whole program into different modules are good programming practice.

However, when a project becomes larger, handling more and more modules would become difficult.

Fortunately, Python is very flexible and there are many good tricks and practice that can help us manage and use modules elegantly. This article will summary them into three key skills. After reading, handling modules would just be a piece of cake for you. 🍰

1. Import Python Modules Skilfully

When we writing programs, using other existed modules is nearly inevitable. Therefore, knowing how to import modules properly is very important. Basically, we all know the template of importing modules in Python:

from A import B

And the from A is optional.

It looks simple, but don’t underestimate it. Here are 3 tips that can help us use it more elegantly and avoid potential bugs.

(1) Don’t use an asterisk to import all things at once

--

--