On Mon, Feb 20, 2012 at 05:46:10PM +0100, Michael Hanselmann wrote: > Am 20. Februar 2012 15:21 schrieb Iustin Pop <[email protected]>: > > --- a/lib/objects.py > > +++ b/lib/objects.py > > - result = dict() > > if diskparams is None: > > result = constants.DISK_DT_DEFAULTS.copy() > > else: > > + result = {} > > # Update the disk parameter values for each disk template. > > # The code iterates over constants.DISK_TEMPLATES because new templates > > # might have been added. > > for template in constants.DISK_TEMPLATES: > > - if template not in diskparams: > > - result[template] = constants.DISK_DT_DEFAULTS[template].copy() > > - else: > > - result[template] = FillDict(constants.DISK_DT_DEFAULTS[template], > > - diskparams[template]) > > + result[template] = FillDict(constants.DISK_DT_DEFAULTS[template], > > + diskparams.get(template, {})) > > Can we have something like “result = dict((dt, FillDict(…)) for dt in > constants.DISK_TEMPLATES]”? /me dislikes filling dictionaries by keys.
Hah, sure, I didn't realise that we can simplify since before the explicit loop was needed :) Will resend. iustin
