[Tutor] problem editing modules and defs
Walter Prins
wprins at gmail.com
Fri Feb 24 20:45:08 CET 2012
Hi Dave,
On 24 February 2012 16:29, David Craig <dcdavemail at gmail.com> wrote:
> Hi,
> I am new to python and have made a couple of definitions. I imported them
> and they worked ok 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.
Did you try completely restarting your Python interpreter? It may be
that you've still got the previous version of your module/function in
memory hence why it's still giving you your old error. You could try
the reload() built in function to get the interpreter to reload your
previously imported module:
http://docs.python.org/library/functions.html#reload
HTH,
Walter
More information about the Tutor
mailing list