Let's say I have the following yaml file, and the value in the 4th line should be None. How to convert string 'None'to None?
CREDENTIALS:
USERNAME: 'USERNAME'
PASSWORD: 'PASSWORD'
LOG_FILE_PATH: None <----------
I already have this:
config = yaml.safe_load(open(config_path, "r"))
username, password, log_file_path = (config['CREDENTIALS']['USERNAME'],
config['CREDENTIALS']['PASSWORD'],
config['LOG_FILE_PATH'])
I would like to know if there is a pythonic way to do this, and not just do:
if log_file_path == 'None':
log_file_path = None
source
share