中学理科1628828 views
MathPython494778 views
英語610986 views
世界の国562648 views
Computer366795 views
雑学1473194 views
高校物理159140 views
中学英語810437 views
高校国語787039 views
中学社会667787 views

Nail

Should I avoid using from ... * imports in Python?

I was taught by co-workers not to use asterisk imports in Python.

from math import *

result = sqrt(16) + cos(0)

In this case, we can use all functions in math standard library. “So nice, because I can omit library names!”, I thought before the errors happened.

The “logger” file is usually imported to many files in our project. Someone imported “log” from logger library and I wrote the code like above example. Then “log” didn’t work properly.

I learn not to use asterisk imports and import a few functions specifically.