May 30, 2007, at 03:14 PM

20070529

Cultural renewal will result when we have not only met the challenge of co–existing with the beast of technologically driven change, but have also learned how to dance with it.

nlightening on top of being illuminating! Discovered it through Daily Python-URL! and Ned Batchelder. I am sure my Italian is nowhere near good enough to understand his thesis but I may try giving it a bash anyway. I can always just look at the pictures :D

The quotation is taken from a poster he made to present his project. It is a brilliant looking work. The dancing part reminded me of Tim Leary in Misc.EvolutionarySurfer. Must go surfing I guess ;)

Yesterday I had a blast coding in Python. I started refactoring the code of a prototype application I wrote over roughly 6 months, that's proving too useful to stay in that state. I am glad to say that I am not as much of a potato programmer as I use to be (cf. 20060122). So today I am going to express openly my love for the setdefault method of dictionary objects!

reference = {}
for s in style:
    reference[s] = {}
    for L in length:
        reference[s][L] = {}
        for m in microns:
            man = [lot for lot in data if lot.style == s and
                    lot.length == L and int(lot.micron) == m and
                    'W' not in lot.prefix]
            bales = sum([lot.bales for lot in man if lot.team != 0])
            if bales:
                average = sum([lot.team * lot.bales for lot in man
                    if lot.team != 0]) / bales
                reference[s][L][m] = {'hm': average, 'bls': bales}
        if len(reference[s][L]) == 0:
            reference[s].pop(L)
    if len(reference[L]) == 0:
        reference.pop(s)

worked but the reference dictionary turned up to be pretty scarce i.e. lots of empty cells i.e. empty dicts, which I decided to get rid of using pop. Then I remembered the setdefault method which does a great job!

reference = {}
for s in style:
    for L in length:
        for m in microns:
            man = [lot for lot in data if lot.style == s and
                    lot.length == L and int(lot.micron) == m and
                    'W' not in lot.prefix]
            bales = sum([lot.bales for lot in man if lot.team != 0])
            if bales:
                average = sum([lot.team * lot.bales for lot in man
                    if lot.team != 0]) / bales
                reference.setdefault(s, {}).setdefault(L, {})[m] =\
                {'hm': average, 'bls': bales}

is as readable and generates the proper reference straight away.

After over 2 months without swimming I went back to the pool, using one of the last 2 tickets I had for Max Dormoy (cf. 20070416). It was a shinfin training session (the first in a long time).

distancetechnic
500 mfreestyle arms only, with fins for body position
500 mfreestyle, with fins
500 mkick board, with fins
500 mfreestyle, no fins

blog comments powered by Disqus