def pull_key_prefix(prefix, d):
    """
    Returns a filtered dict of all the items of d that start with
    the given key prefix, plus a dot, with that prefix removed.
    """
    pd = prefix + "."
    lpd = len(pd)
    return {k[lpd:]: v for k, v in d.items() if k.startswith(pd)}

    Returns a filtered dict of all the items of d that start with
    the given key prefix, plus a dot, with that prefix removed.
    
util/runningstats.py