Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #access #file #root #folder #python #project
ADD COMMENT
Topic
Name
9+4 =