pyyaml and using quotes for strings only
I have the following YAML file: --- my_vars: my_env: "dev" my_count: 3 When I read it with PyYAML and dump it again, I get the following output: --- my_vars: my_env: dev my_count: 3 The code in question: with open(env_file) as f: env_dict = yaml.load(f) print(yaml.dump(env_dict, indent=4, default_flow_style=False, explicit_start=True)) I tried using the default_style parameter: with open(env_file) as f: env_dict = yaml.load(f) print(yaml.dump(env_dict, indent=4, default_flow_style=False, explicit_start=True, default_style='"')) But now I get: --- "my_vars": "my_env": "dev" "my_count": !!int "3