def getDictValues(d, fields, defaults=None):
    """Returns a list of values from a dictionary using the given seq of `fields`.
    If `defaults` is given, it should be same length as `fields`."""
    if defaults is None:
        return [d[f] for f in fields]
    assert len(defaults) == len(fields)
    return [d.get(f, de) for f, de in zip(fields, defaults)]