1

I've got file named recommend.py. It has a dict data named critics.

When I try to reload it in the interpreter it gives the following error:

>>> from recommend import critics >>> reload(recommend.py) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'recommend' is not defined >>> 

I'm new to python. Please help me.

1
  • Depsite the obvious error - why are you trying to do this? Commented Nov 19, 2012 at 14:37

2 Answers 2

7

recommend.py is parsed as recommend . py which means that python looks for an object bound to the name recommend and then tries to get the py attribute from it. That doesn't work because you don't have an object named recommend in the current namespace and because even if you did have an object bound to that name, it probably wouldn't have an attribute py.

Of course, you'll need to give reload an actual module object. Something more like:

import recommend reload(recommend) 
Sign up to request clarification or add additional context in comments.

Comments

1

reload() takes a module object, not a filename:

import recommend reload(recommend) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.