python how to get project location 1

python how to get project location

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

Here is what the above code is Doing:
1. We’re importing the os module, which is a built-in Python module for interacting with the operating system.
2. We’re using the os.path.dirname() function to get the directory name of the current file.
3. We’re using the os.path.abspath() function to get the absolute path of the current file.
4. We’re using the os.path.join() function to join the directory name and the file name together.
5. We’re assigning the result to the BASE_DIR variable.

Similar Posts