I have a code which, at some point shows a warning, I think that it is having a problem calculating a mean()
I would like to know if there is any way to force python to tell me where, or which line, or whatever more information than just this message:
C:\Python27\lib\site-packages\numpy\core\_methods.py:55: RuntimeWarning: Mean of empty slice.
warnings.warn("Mean of empty slice.", RuntimeWarning)
C:\Python27\lib\site-packages\numpy\core\_methods.py:79: RuntimeWarning: Degrees of freedom <= 0 for slice
warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning)
I do not know if it is possible to "catch" a warning.....If I have any error, usually I am using traceback package:
import traceback
And then I usually do:
try:
#something
except:
print traceback.format_exc()