What you are looking at can be done easily by using
isfile function of
Official documentation of
os.path.isfile - Return True if path refers to a directory entry that is a symbolic link. Always False if symbolic links are not supported by the Python runtime.
It can be done as follows -
>>> import os
<function isfile at 0x0205B1F0>
Above code is the output of python.exe and there is a file README.txt adjacent to it.
Second command is just to show that os.path.isfile is a function.
We can pass the complete path or the absolute path to this function(as show in command 3, 4 and 5).