Configparser Integers

Ace NA picture Ace NA · Nov 11, 2015 · Viewed 10.2k times · Source

I am not sure what I am doing wrong. Previous the code was this:

volume = min(60, max(30, volume))

However after trying with configparser I keep getting a 500 error on my Twilio Server.

volume = min(configParser.get('config_searchandplay', 'volume_max'), max(configParser.get('config_searchandplay', 'volume_min'), volume)) #Max Volume Spam Protection

CONFIG.ini

[config_searchandplay]
#Volume Protection
volume_max = 90
volume_min = 10 

Answer

Eli picture Eli · Mar 5, 2017

You should use:

ConfigParser.getint(section, option)

Rather then casting.

volume = min(configParser.getint('config_searchandplay', 'volume_max'), max(configParser.getint('config_searchandplay', 'volume_min'), volume)) #Max Volume Spam Protection