[Tutor] problem editing modules and defs

David Craig dcdavemail at gmail.com
Fri Feb 24 17:11:20 CET 2012

I am new to python and have made a couple of definitions. I imported 
them and they worked ok. I they worked except for one which gave me the 
error "NameError: global name 'np' is not defined". I then edited my 
script for the def to include "import numpy as np" saved it and imported 
the def again. However, it still gives me the same error. I know I have 
to be doing something basic wrong but cant figure it out, anyone know 
what I am doing wrong. The def is below.

import numpy as np

def find_nearest(array,value):
     return array[idx]

More information about the Tutor mailing list