Through this article, we have analyzed why Python does not recommend using one line to import all modules. Friends who are interested can learn more.
Python does not recommend using one line to import all modules. Instead, it is recommended to use multiple lines of import to import modules. More for operational convenience reasons than import barney, betty, wilma, fred, bambam, pebbles are easier to find.
Only declare one module per line, so you don’t need to work hard to find where the module is;
When moving a module, just move the entire line;
When copying multiple modules to other Python files, you only need to copy and paste a few lines, instead of struggling to find the module you want in a line of import statements.
Once the module is modified, you can directly know which module has the error based on the number of error lines. , and one line of import will be troublesome;
Summary
Multi-line import is more for the convenience of editing (copying, pasting, deleting) and maintenance, and the ease of Searching seems trivial, since most people would write import at the beginning of a Python file, and searching the front of the file shouldn't be difficult.
Analyze the method of importing modules in python at different levels of directories
The above is the detailed content of Problems with one-line and multi-line import modules in Python_python. For more information, please follow other related articles on the PHP Chinese website!