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.
recommend.pyis parsed asrecommend . pywhich means that python looks for an object bound to the namerecommendand then tries to get thepyattribute from it. That doesn’t work because you don’t have an object namedrecommendin the current namespace and because even if you did have an object bound to that name, it probably wouldn’t have an attributepy.Of course, you’ll need to give
reloadan actual module object. Something more like: