What is the right way to import a package?

Christian Gollwitzer auriocus at gmx.de
Sat Nov 14 16:59:11 EST 2015


Am 14.11.15 um 21:00 schrieb fl:
> from numpy import *
> dt = 0.1
> # Initialization of state matrices
> X = array([[0.0], [0.0], [0.1], [0.1]])
>
> # Measurement matrices
> Y = array([[X[0,0] + abs(randn(1)[0])], [X[1,0] + abs(randn(1)[0])]])
>
> When the above content is inside a .py document and running, there will be
>   an error:
>
> ---> 15 Y = array([[X[0,0] + abs(randn(1)[0])], [X[1,0] + abs(randn(1)[0])]])
>       16 #Y = ([[X[0,0]], [X[1,0] + 0]])
>
> NameError: name 'randn' is not defined
>
> But when I run the above line by line at the console (Canopy), there will be
> no error for the above line.

Maybe Canopy is doing a

	from pylab import *

for you?

	Christian




More information about the Python-list mailing list