Pedro Lacerda added the comment: I also never found a mixture of sectionless options followed by sectioned options. So an unnamed section that is also the DEFAULTSECTION will probably work.
In this patch when `default_section=None` is passed to `RawConfigParser` it will parse top level options into the default section and skip writing its title. As drawback, default options is not showed in `options()` or `has_section()` reducing it usefulness. It works with `items()` and `keys()` however. > Using DEFAULTSECT for this purpose is equally wrong since it would > silently inject default values to every section I disagree with that because I really *never* found in wild a file where it will happen. > All in all, it comes down to the question whether the programmer > expects section-less configuration. If not, the '' section will not be > helpful anyway. If yes, then it's desirable to be able to specify a > section name for global options at *read time*. Pass a name at read time will improve the API as `sections()` and `has_section()` will work as usual and not like a DEFAULTSECTION. Please look my patch and tell if it's acceptable, if you prefer that a section name must be given at read and write time we can manage it. It's my first post in this tracker and I'm very glad that I got it working even if not merged! ---------- keywords: +patch nosy: +Pedro Lacerda versions: -Python 3.5 Added file: http://bugs.python.org/file43345/nosection.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22253> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com