Comparing Dictionaries

Kenneth Love klove at tax.ok.gov
Fri Jul 27 21:11:02 CEST 2007


At 04:42 AM 7/27/2007, Ali wrote:
>On Jul 26, 10:18 pm, Kenneth Love <kl... at tax.ok.gov> wrote:
> > Hello,
> >
> > I am new to Python, but not programming.  I would like to start my
> > Python career by developing programs according to the "best practices"
> > of the industry.  Right now, that appears to be unit tests, patterns,
> > and source code control.
>
>I am not sure about "best", but one of my "favourite practices" is to
>not re-write code that other people have written, and have released
>under licenses that allow you to do anything with it.
>
> > So, I am trying to write a unit test for some code that reads a Windows
> > style INI file and stores the section, key, and values in a dictionary
>
>So, in the standard library: 
>http://docs.python.org/lib/module-ConfigParser.html
>And if you want a more involved approach: 
>http://www.voidspace.org.uk/python/configobj.html
>
>Ali

The published recipe (based on ConfigParser) did not handle my INI
files.  I have periods in both the section names and the key names.
The INI files contents were developed according to an internally
defined process that other non-Python programs rely on.  The published
recipe *did not work* with this scenario.

Believe me, not modifying 3rd-party code is something I prefer and
already practice.  The code has to work first.

In case anyone is curious, here is a link to the original:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65334

I combined the load/save routines, slogged through the unfamiliar
syntax, changed the section/key separator to '$', and started
writing unit tests.

Sincerely,
Kenneth Love


-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Kenneth Love                   |         Oklahoma Tax Commission
DP Programmer/Analyst          |         Information Technology
(405) 522 - 5864               |         http://www.tax.ok.gov/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 





More information about the Python-list mailing list