Posted on

The default file path for python is the path of ‘__main__‘, regardless of where the called module is located. To know where the module is, following is a possible way.

filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))

default_config_file = path + '/../../config/config.json'

References

  1. https://stackoverflow.com/questions/2632199/how-do-i-get-the-path-of-the-current-executed-file-in-python#answer-44592299

Leave a Reply

Your email address will not be published. Required fields are marked *