Dictionary question

Brian Elmegaard brian at rkspeed-rugby.dk
Tue Jul 18 09:01:27 EDT 2006


John Machin <sjmachin at lexicon.net> writes:

> 2. Put spaces around operators -- in general, RTFStyleGuide
>    http://www.python.org/dev/peps/pep-0008

I din't know it. Thanks.

> Only you know what *really* meaningful names you should be using.

I have better names in my running code.

> mykey = a + c
> newvalue = x + e
> lastdict = dictlist[-1]
> if mykey not in lastdict or lastdict[mykey] < newvalue:
>      lastdict[mykey] = newvalue

Better, thanks.

> 4. Add some comments about what you are trying to achieve. What is the
>    point of keeping the two dicts in a list??? Can't you give them
>    names, like rawdatadict and maxdict?

It's a dynamic programming problem, so this will contain as many dicts
as hours in the year.

-- 
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
Rugbyklubben Speed Scandinavian Open 7s Rugby http://www.rkspeed.dk



More information about the Python-list mailing list