Message 172015 - Python tracker (original) (raw)

I could consider relaxing the parameters on fileConfig such that instead of accepting just a string or a file-like object, it additionally accepts a ConfigParser instance. More specifically:

def fileConfig(file_or_fname_or_cp, defaults=None): if isinstance(file_or_fname_or_cp, RawConfigParser): cp = file_or_filename_or_cp else: cp = ConfigParser.ConfigParser(defaults) if hasattr(cp, 'readfp') and
hasattr(file_or_fname_or_cp, 'readline'): cp.readfp(file_or_fname_or_cp) else: cp.read(file_or_fname_or_cp)

formatters = _create_formatters(cp)

This will only require (in addition to the above) small tweaks to docs and tests. It would appear to fit the bill for your use case. Do you agree?