Join Nostr
2024-11-26 03:09:00 UTC

Trey Hunner 🐍 on Nostr: In Python, instead of this: BASE_DIR = ...

In Python, instead of this:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

I prefer this:

BASE_DIR = pathlib.Path(__file__).resolve().parent.parent

For more on the magic of Python's pathlib module, check out the article I published last week: https://pym.dev/pathlib-module

#Python #pathlib