In 2016 the best way is still using os.path.isfile
:
>>> os.path.isfile('/path/to/some/file.txt')
Or in Python 3 you can use pathlib
:
import pathlibpath = pathlib.Path('/path/to/some/file.txt')if path.is_file(): ...
In 2016 the best way is still using os.path.isfile
:
>>> os.path.isfile('/path/to/some/file.txt')
Or in Python 3 you can use pathlib
:
import pathlibpath = pathlib.Path('/path/to/some/file.txt')if path.is_file(): ...