Never use from module import *
.
The "concision" in this case is an illusion.
The *
removes a level of determism to your code, making some static correction check features impossible (for example, if you enter a wrong variable name, no tool will be able to point this out, since there is no way to know if the wrong name exists between what was imported with "*").
And that disrupts not only tools, but human programmers: in complex code with multiple Mports, after a week or two, you see a call function, and you can’t know where it came from, for example.
And it’s even dangerous: if you have more than one import with "*" in the same module, an import that comes after could overwrite names that had already been imported - and you won’t know that. Even worse: this over-written import could happen in a later version of a library, so that your code works when it is done, and mysteriously stops working when updating some dependency.
So: no.
As for "concision", it is relative. The syntax of import
in Python is very flexible, and you probably have to keep this desired concision even without introducing the ambiguity of *
: you can import only the names that need some module, for example doing from modulo import metodo1, metodo2
, or, in the case of a module from which you will call a lot, use only a smaller name for it, such as import numpy as np
or import typing as T
.
The minireview is quite a part of your question. There is a separate stackoverflow site for this - https://codereview.stackexchange.com/ . If you can’t even post in English I think it’s okay to ask for the review here, but ask a separate question, and paste the code here (no external links)
– jsbueno
ok @jsbueno already withdrew the mini-review from the question, sorry
– Mateus
not - all right you ask - I only answered in the appropriate way for this context: as a comment.
– jsbueno