On this page
genericpath.samefile
Prev: genericpath.lexists | Up: genericpath | Next: genericpath.sameopenfile
Rel: genericpath.commonprefix, genericpath.exists, genericpath.getatime, genericpath.getctime
Ref: docs.python.org — genericpath.samefile
Tags: #public #python3 #stdlib #genericpath
Import
import genericpath
from genericpath import samefile
Signature & Overview
genericpath.samefile(f1, f2)
Test whether two pathnames reference the same actual file or directory This is determined by the device number and i-node number and raises an exception if an os.stat() call on either pathname fails.
Usage
import os
assert os.path.samefile(".", os.path.abspath(".")) is True
Gotchas
- Compares inode + device ID, not string paths—reliably detects symlinks and hard links pointing to the same file.
REPL Inspect
from genericpath import samefile
help(samefile)
Linked from
Related notes
- tuts/python3/stdlib_module/genericpath/lexists Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/sameopenfile Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/genericpath/commonprefix Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/exists Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getatime Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getctime Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getmtime shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getsize shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/isdevdrive shared tags: #genericpath, #stdlib