I want to print the content of a Python config parser object.
The following code
for section in system_config.config.sections():
print ("\n[" + section + "]")
for (key, value) in system_config.config.items(section):
print(key + "=" + value)
prints
[GENERAL]
data_roots=[["c:\\data", "/data"] , ["d:\\data2", "/data2"]]
test_data_folder=c:\data\atp-test-data
mount_render_python_apps=false
mount_render_modules=false
host_memory=24
host_number_of_cores=4
at_core_threads=15
For readability, the following is preferable:
[GENERAL]
data_roots = [["c:\\data", "/data"] , ["d:\\data2", "/data2"]]
test_data_folder = c:\data\atp-test-data
mount_render_python_apps = false
mount_render_modules = false
host_memory = 24
host_number_of_cores = 4
at_core_threads = 15
In C++ this can be achieved by setting the 'width' of the first field when using the stream operator '<<'.
Question is, how to do this with Python?