小学社会308888 views
高校生物550171 views
数学講師2860658 views
高校国語786125 views
いろは2992226 views
Computer365801 views
英語609049 views
小学算数1196391 views
世界の国561299 views
りんご196284 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.