configparser error reading relative file path

Solutions on MaxInterview for configparser error reading relative file path by the best coders in the world

showing results for - "configparser error reading relative file path"
Bryony
26 Aug 2017
1# the current directory can be changed by your program [or a module] 
2# and it is in general not the directory of your program file
3import configparser, os
4config = configparser.ConfigParser()
5config.read(os.path.join(os.path.dirname(__file__), 'config.cfg'))