Deleting the module from sys.modules
and re-importing could be a start, although I haven't tested it beyond the below:
import itertools
itertools.TEST = 7
reload(itertools)
print itertools.TEST
# 7
import sys
del sys.modules['itertools']
import itertools
print itertools.TEST
#Traceback (most recent call last):
# File "/home/jon/stackoverflow/12669546-reload-with-reset.py", line 10, in <module>
# print itertools.TEST
# AttributeError: 'module' object has no attribute 'TEST'
Test with 3rd party module
>>> import pandas
>>> import sys
>>> del sys.modules['pandas']
>>> import pandas
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import pandas
File "/usr/local/lib/python2.7/dist-packages/pandas-0.7.3-py2.7-linux-x86_64.egg/pandas/__init__.py", line 10, in <module>
import pandas._tseries as lib
AttributeError: 'module' object has no attribute '_tseries'
>>> to_del = [m for m in sys.modules if m.startswith('pandas.')]
>>> for td in to_del:
del sys.modules[td]
>>> import pandas
>>> # now it works