Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Isn't that basically the same end result as using json.loads except a different format (that has no actual spec).


JSON does not support comments nor string interpolation. Python ConfigParser language does.


True, you do get string interpolation but the comment support in ConfigParser isn't very good. Although actually they may have fixed some of that in Python 3 but I'm still using workarounds.

To be clear, I am not suggesting using JSON for config, I think that would be my last choice. My point is that ConfigParser isn't really an alternative to rolling your own if you want decent validation etc (those spec files are horrible to use). You very quickly need to start extending ConfigParser to the point where you've started rolling your own. And at that point you'd be better off with one of the other (tested) solutions already suggested.


What's wrong with the comment support?

You can't have comments at the end of a line, but that's sort of the nature of supporting arbitrary strings as values. I don't want my users to have to quote or escape special characters if they happen to want to use them. They're not programmers.

    # The note to display
    note = Our #1 customer!
rather than

    name = Our \#1 customer  # The note to display.
or

    name = "Our #1 customer"  # The note display


> What's wrong with the comment support?

Comments are simply ignored. You can't read them. You might want to read a commented config file in, make a change to a setting and then write that out. You can't do that. But you can write comments using the 'allow_no_value=True' hack, as long as long as you put it in a section.

> You can't have comments at the end of a line

You can. You need to use ';' for inline comments and you must proceed it with whitespace. Are your users ready for that?


> make a change to a setting and then write that out

Very good point.

> You can. You need to use ';' for inline comments

I have some bugs to fix.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: