This is possible when you import a module in shell and then make changes to the file but you are still using the same old module in shell. The solution is to reload the module or re-start the shell. This happens because the shell we try to load the latest code based up the error stack and display it to you.
# so.py
def func():
print(foo.bar)
>>> import so