Answers for "why we need root directory python"

2

Python project root dir

import os
ROOT_DIR = os.path.abspath(os.curdir)
Posted by: Guest on April-28-2021
0

how to access a file from root folder in python project

from from_root import from_root, from_here

# path to config file at the root of your project
# (no matter from what file of the project the function is called!)
config_path = from_root('config.json')

# path to the data.csv file at the same directory where the callee script is located
# (has nothing to do with the current working directory)
data_path = from_here('data.csv')
Posted by: Guest on August-25-2021

Browse Popular Code Answers by Language