To import all numpy modules at once instead of one at a type as needed, type from numpy import *
. The import *
command is dangerously convenient — we will sometimes use it ourselves, being not as pure in thought as others might be on this issue— but take two considerations in mind: (1) you are importing code you don't need in addition to that you do, and (2) if you have any already defined functions that have the same name as a numpy function, those functions will be overwritten. This is particularly prone to happen with mathematical functions. For example, the math package math
, the complex mathematics package cmath
, the numerical python package numpy
, and the numerical calculation of uncertainties package uncertainties
all have trigonometric functions called sin
and cos
! If you only need the sine and cosine functions from the numerical python package numpy but , typing from numpy import sin, cos
The second method requires a prefix before each use of a module. We call this the traditional numpy import style.