(elements)
return itertools.chain.from_iterable(itertools.combinations(elements, r)
                                         for r in range(len(elements)+1))
Generates the powerset of the given elements set.

    E.g., powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
Generates the powerset of the given elements set.
Generates the powerset of the given elements set .
def powerset(elements):
    """Generates the powerset of the given elements set.

    E.g., powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
    """
    return itertools.chain.from_iterable(itertools.combinations(elements, r)
                                         for r in range(len(elements)+1))
def powerset ( elements ) : return itertools . chain . from_iterable ( itertools . combinations ( elements , r ) for r in range ( len ( elements ) + 1 ) )