Code review comment for lp:~kylehuff/awn-extras/0.4-bandwidth-monitor

Revision history for this message
Mark Lee (malept) wrote :

> + i = 0
[...]
> + for device_pref in prefs:
> + dpv = device_pref.split("|")
> + if dpv[0] == model[path][0]:
> + ''' If the current column is 1 or 2, it is a checkbox,
> + so transpose from bool to int '''
> + dpv[col_number] = parameter
> + prefs[i] = "%s|%s|%s|%s|%s" % (dpv[0], dpv[1], dpv[2], dpv[3], dpv[4])
> + i += 1

Because I'm a pedant, this could be rewritten as follows:

for i, device_pref in enumerate(prefs):
    dpv = device_pref.split('|')
    if dpv[0] == model[path][0]:
        ''' If the current column is 1 or 2, it is a checkbox,
        so transpose from bool to int '''
        dpv[col_number] = parameter
        prefs[i] = '|'.join(dpv)

« Back to merge proposal