LaTeX958874 views
高校生物550414 views
Computer366298 views
中学数学622271 views
高校化学2916692 views
小学社会309069 views
中学英語809923 views
ヒストリア286524 views
世界の国561912 views
小学理科718157 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.