<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:56.7pt 42.5pt 56.7pt 85.05pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText>I came across a nice combo solution yesterday: little embedded json lists inside ConfigParser's config (from&nbsp; <a href="http://stackoverflow.com/a/9735884">http://stackoverflow.com/a/9735884</a>):<o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'><o:p>&nbsp;</o:p></p><p class=MsoPlainText style='margin-left:.5in'>[Foo] <o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'>fibs: [1,1,2,3,5,8,13]<o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'><o:p>&nbsp;</o:p></p><p class=MsoPlainText style='margin-left:.5in'>&gt;&gt;&gt; json.loads(config.get(&quot;Foo&quot;,&quot;fibs&quot;)) <o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'>[1, 1, 2, 3, 5, 8, 13]<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Notice that you can actually span values over multiple lines, useful for long strings, as long as you add some tab/whitespace indent:<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>[Foo] <o:p></o:p></p><p class=MsoPlainText>fibs: [<o:p></o:p></p><p class=MsoPlainText>&nbsp; &quot;1&quot;,<o:p></o:p></p><p class=MsoPlainText>&nbsp; &quot;1&quot;,<o:p></o:p></p><p class=MsoPlainText>&nbsp; &quot;2&quot;,<o:p></o:p></p><p class=MsoPlainText>&nbsp; &quot;3&quot;,<o:p></o:p></p><p class=MsoPlainText>&nbsp; &quot;5&quot;,<o:p></o:p></p><p class=MsoPlainText>&nbsp; &quot;8&quot;,<o:p></o:p></p><p class=MsoPlainText>&nbsp; &quot;13&quot;<o:p></o:p></p><p class=MsoPlainText>&nbsp; ]<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>The only annoyance is that you have to use double quotes (json), and you can&#8217;t put a comma after last string.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>Dima.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText><a name="_MailEndCompose"><o:p>&nbsp;</o:p></a></p><p class=MsoPlainText>-----Original Message-----<br>From: Neil [mailto:neilkumar@gmail.com] <br>Sent: Saturday, July 14, 2012 10:33 AM<br>To: Brent Tubbs<br>Cc: baypiggies@python.org<br>Subject: Re: [Baypiggies] configuration parser using python modules?<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>I like YAML too. I feel like JSON is only slightly better than XML as for being human editable (assuming its been pretty printed, otherwise a huge JSON document can be worse off as far as readability goes compared to XML) -- as it doesn't allow adding comments (which I think is very important for configuration files) and it barfs on things like a trailing comma on a list or hash definitions.<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>-neil<o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p><p class=MsoPlainText>On Sat, Jul 14, 2012 at 8:43 AM, Brent Tubbs &lt;<a href="mailto:brent.tubbs@gmail.com"><span style='color:windowtext;text-decoration:none'>brent.tubbs@gmail.com</span></a>&gt; wrote:<o:p></o:p></p><p class=MsoPlainText>&gt; My peeve against ConfigParser is that if you want a list of things, <o:p></o:p></p><p class=MsoPlainText>&gt; you end up faking it with some incomplete-looking syntax<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; [my_things]<o:p></o:p></p><p class=MsoPlainText>&gt; thing1 =<o:p></o:p></p><p class=MsoPlainText>&gt; thing2 =<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; That makes me sad.&nbsp; (I'm looking at you, .hgrc.)<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; These days all my config files are YAML.&nbsp; You get all the lists and <o:p></o:p></p><p class=MsoPlainText>&gt; hashes that JSON can do, but you can leave out all the quote marks and <o:p></o:p></p><p class=MsoPlainText>&gt; curly braces, which is a big plus for readability.<o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; On Fri, Jul 13, 2012 at 10:38 PM, Ian Zimmerman &lt;<a href="mailto:itz@buug.org"><span style='color:windowtext;text-decoration:none'>itz@buug.org</span></a>&gt; wrote:<o:p></o:p></p><p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&gt; David&gt; app written in Python, some pub-sub stuff written in JS on <o:p></o:p></p><p class=MsoPlainText>&gt;&gt; David&gt; Node<o:p></o:p></p><p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&gt; In this case, JSON seems like an obvious choice for a config format <o:p></o:p></p><p class=MsoPlainText>&gt;&gt; :-P<o:p></o:p></p><p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&gt; Personally, I try to just use eval(read(open(CONFFILE))) whenever <o:p></o:p></p><p class=MsoPlainText>&gt;&gt; remotely possible , guarded against surprises of course.<o:p></o:p></p><p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&gt; The ConfigParser module is quite unpleasant IMO.&nbsp; Particularly <o:p></o:p></p><p class=MsoPlainText>&gt;&gt; because the natural structure to hold such information is either a <o:p></o:p></p><p class=MsoPlainText>&gt;&gt; dictionary or an object with named fields, but that's not what ConfigParser gives you.<o:p></o:p></p><p class=MsoPlainText>&gt;&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;&gt; --<o:p></o:p></p><p class=MsoPlainText>&gt;&gt; Ian Zimmerman<o:p></o:p></p><p class=MsoPlainText>&gt;&gt; gpg public key: 1024D/C6FF61AD<o:p></o:p></p><p class=MsoPlainText>&gt;&gt; fingerprint: 66DC D68F 5C1B 4D71 2EE5&nbsp; BD03 8A00 786C C6FF 61AD <o:p></o:p></p><p class=MsoPlainText>&gt;&gt; <a href="http://www.gravatar.com/avatar/c66875cda51109f76c6312f4d4743d1e.png"><span style='color:windowtext;text-decoration:none'>http://www.gravatar.com/avatar/c66875cda51109f76c6312f4d4743d1e.png</span></a><o:p></o:p></p><p class=MsoPlainText>&gt;&gt; Rule 420: All persons more than eight miles high to leave the court.<o:p></o:p></p><p class=MsoPlainText>&gt;&gt; _______________________________________________<o:p></o:p></p><p class=MsoPlainText>&gt;&gt; Baypiggies mailing list<o:p></o:p></p><p class=MsoPlainText>&gt;&gt; <a href="mailto:Baypiggies@python.org"><span style='color:windowtext;text-decoration:none'>Baypiggies@python.org</span></a><o:p></o:p></p><p class=MsoPlainText>&gt;&gt; To change your subscription options or unsubscribe:<o:p></o:p></p><p class=MsoPlainText>&gt;&gt; <a href="http://mail.python.org/mailman/listinfo/baypiggies"><span style='color:windowtext;text-decoration:none'>http://mail.python.org/mailman/listinfo/baypiggies</span></a><o:p></o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt;<o:p>&nbsp;</o:p></p><p class=MsoPlainText>&gt; _______________________________________________<o:p></o:p></p><p class=MsoPlainText>&gt; Baypiggies mailing list<o:p></o:p></p><p class=MsoPlainText>&gt; <a href="mailto:Baypiggies@python.org"><span style='color:windowtext;text-decoration:none'>Baypiggies@python.org</span></a><o:p></o:p></p><p class=MsoPlainText>&gt; To change your subscription options or unsubscribe:<o:p></o:p></p><p class=MsoPlainText>&gt; <a href="http://mail.python.org/mailman/listinfo/baypiggies"><span style='color:windowtext;text-decoration:none'>http://mail.python.org/mailman/listinfo/baypiggies</span></a><o:p></o:p></p><p class=MsoPlainText><o:p>&nbsp;</o:p></p></div></body></html>