Modules and import
The forms of import, what each one puts in your namespace, and why import * is discouraged.
Overview
The three forms
import math # math.sqrt(9)
from math import sqrt # sqrt(9)
import numpy as np # np.array(...)
The first keeps the module as a prefix. That is a feature: reading math.sqrt a hundred lines later tells you immediately where it came from, and it cannot collide with anything of yours.
The second is shorter and right when you use one or two names heavily and there is no ambiguity.
as renames on the way in, for length (numpy as np) or to avoid a clash with a name you already have.
imports.py
import_care.py
Worth knowing
import math keeps the module name as a prefix, which shows where a function came from.from math import sqrt puts sqrt straight into your namespace.import * hides where names came from and silently overwrites your own.