Because the First state of the second execution is Incorrect, the resulting computation is also Incorrect. Mainly because inevitably the 2nd execution will update the ultimate condition with the wrong result.For anyone who is on Python two, you could backport the pathlib module from pypi, pathlib2, or usually Look at isfile from the os.route module