Rob Cliffe wrote: > I was surprised to find that in configparser, getboolean() does not raise > KeyError for a non-existent config parameter. > Is there a good reason for this?
History and backwards compatibility. The configparser module has some years on it. The rationale for this sort of thing is this: It's a common enough case for a file to not contain a key that writing a try/expect can be seen as too cumbersome compared to an "is None" test. Reasonable people may disagree, preferring a KeyError if no fallback is provided, but it's too late to change now. regards, Anders -- https://mail.python.org/mailman3//lists/python-list.python.org