Release: configy 0.3
Comments are not part of the JSON specification, but it is very useful (and sometimes necessary) to have well commented configuration files. I have added support for comments (multi-line and in-line) to configpy, therefore if a configuration has comments it is not JSON. Internally, configpy
just strips the comments before parsing. Here’s a brief example:
config_str = """
/* We can use single line */
/* and multi-line
Javascript like comments */
{
"var_a": "AAAA", // or simple in-line comments too
/* we can mix comments everywhere */
"var_b": "You must escape \/* slashes in name or value strings *\/",
"var_c": "A longer string \/\/ like this one"
}
"""
config = Config(config_str)
assert "AAAA" == config.var_a
assert "You must escape /* slashes in name or value strings */" == config.var_b
assert "A longer string // like this one" == config.var_c
You can grab this release from PyPI.