Test whether a path is a regular file
(path)
| 25 | # This follows symbolic links, so both islink() and isdir() can be true |
| 26 | # for the same path on systems that support symlinks |
| 27 | def isfile(path): |
| 28 | """Test whether a path is a regular file""" |
| 29 | try: |
| 30 | st = os.stat(path) |
| 31 | except (OSError, ValueError): |
| 32 | return False |
| 33 | return stat.S_ISREG(st.st_mode) |
| 34 | |
| 35 | |
| 36 | # Is a path a directory? |
no test coverage detected