def subdict(fromdict, fields, default=None,  force=False):
    """
    Return a dictionary with the specified selection of keys from `fromdict`.
    If `default` is not None or `force` is true, set missing requested keys to
    the value of `default`.
    (Argument `force` is only needed if the desired default is None)
    """
    if default is not None:
        force = True
    return { k: fromdict.get(k, default) for k in fields if k in fromdict or force }