Code execution when importing a module in Python is a bad practice?
📁 вопрос, ии
Several times I met the mention that the fulfillment of the code when importing module is poor practice. At the same time, I could not find explanations to this statement anywhere. There are two questions.
the first: Why is the execution of the code when importing the module is considered a bad practice?
the second: What is the performance of the code, in the context of this statement? Assigning the values of a global variable, performing functions or something else? After all, the definition of classes and functions in this module, as well as the import of other modules (in this module that we import), because this can also be considered "" code "" "?
Ответов пока нет.
Войдите чтобы оставить ответ
Блоги
Как отправить HTTP-запрос с requests