中学数学621382 views
いろは2986023 views
りんご192546 views
高校化学2913383 views
高校物理158224 views
小学社会308636 views
小学算数1194618 views
高校倫理1433119 views
LaTeX957300 views
教育148875 views

Nail

Help
Tools

English

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.