Inspired Python
>>> from pathlib import Path
>>> p = Path('/home/inspiredpython/')
# Append `hello.txt` to the path
>>> hello = p / 'hello.txt'
>>> print(hello)
# Check if the file exists
>>> hello.exists()

Python Pathlib Tips: Building Paths

You can join files and paths to any pathlib Path with / – and the newly-built path is itself a Path object!

Be Inspired Get Python tips sent to your inbox

We'll tell you about the latest courses and articles.

Absolutely no spam. We promise!