13 lines
300 B
Python
13 lines
300 B
Python
# files/existence.py
|
|
from pathlib import Path
|
|
|
|
p = Path('fear.txt')
|
|
path = p.parent.absolute()
|
|
|
|
print(p.is_file()) # True
|
|
print(path) # /Users/fab/srv/lpp3e/ch08/files
|
|
print(path.is_dir()) # True
|
|
|
|
q = Path('/Users/fab/srv/lpp3e/ch08/files')
|
|
print(q.is_dir()) # True
|