Python: configparser.InterpolationSyntaxError: '$' must be followed by '$' or '{', found: '$!'

42 views Asked by At

I have psw: Test123$! string in my configs.ini and tryin to read it with the following code will result in configparser.InterpolationSyntaxError: '$' must be followed by '$' or '{', found: '$!' error:

configs = configparser.RawConfigParser()
configs._interpolation = configparser.ExtendedInterpolation()
configs.read(configs_path)

print(configs.get('app', 'psw', fallback=''))

I've seen other similar posts but all of them was referring to % as special character, not $! I tried escaping it inserting a double symbol (psw: Test123$$!) as suggested for the % symbol, but it didn't work. I can't find any reference to dollar symbol in the docs unless if it is followed by an open graph symbol (${)...so how to obtain a string containing a dollar symbol from an .ini file with configparser?

0

There are 0 answers