diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-10-03 14:15:46 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-10-03 14:15:46 -0500 |
| commit | 44d781df96d67e5ee301c394677b60bf77d30fce (patch) | |
| tree | 8714494d580b32405ddb7b9b09da78fcaafc1276 /README.md | |
| parent | Add docstrings to pytest fixtures (diff) | |
| download | config-file-44d781df96d67e5ee301c394677b60bf77d30fce.zip | |
Fix issue #25 (INI parser isn't converting back to string)
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -290,14 +290,16 @@ config.delete('section.list_key') config.save() ``` -### Using `stringify()` +### Stringifying our ConfigFile -`stringify()` shows us our configuration file, with any changes we've made, -as a string. `stringify()` will always show us our latest changes since it -is stringify-ing our internal representation of the configuration file, not -just the file we've read in. +To retrieve the file as a string, with any changes we've made, we can use the +built-in `str()` method on the ConfigFile. This will always show us our latest changes since it is stringify-ing our internal representation of the configuration file, not just the file we've read in. ```python +str(config) +>>> '[section]\nnum_key = 5\nstr_key = blah\nbool_key = true\nlist_key = [1, 2]\n\n[second_section]\ndict_key = { "another_num": 5 }\n\n' + +# Depreciated but also works. config.stringify() >>> '[section]\nnum_key = 5\nstr_key = blah\nbool_key = true\nlist_key = [1, 2]\n\n[second_section]\ndict_key = { "another_num": 5 }\n\n' ``` |