When you start developing larger applications, and
especially when you start using multiple modules like
SciPy and the
matplotlib plotting system, it can become
difficult to remember which functions came from which
The cure for this problem is to import the entire module and
then refer to things inside the module using the syntax
is the name of the
is the name of the item within the module.
Place a line like this with your other
import numpy as np
Then you use
np.array() to create an array, or
np.arange() to create an arithmetic
progression array, and so forth.
In the rest of this document, we will assume that you use the second form of import. For example:
>>> import numpy as np >>> print np.pi, np.e 3.14159265359 2.71828182846 >>> print np.arange(0.0, 1.0, 0.1) [ 0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
The term namespace hygiene refers to the commendable practice of keeping items from different namespaces separate, so you can tell what comes from where.