import itertools


def powerset(s, as_set=False):
    """Returns the power set of a set (set of all subsets).

    as_set: If ```True```, returns set of frozensets, otherwise
            returns list of sets."""
    res = []
    for size in range(len(s)+1):
        for ele in map(frozenset if as_set else set, itertools.combinations(s, size)):
            res.append(ele)
    return set(res) if as_set else res