xxxxxxxxxx
from functools import reduce
s = {1, 2, 3}
ps = lambda s: reduce(lambda P, x: P + [subset | {x} for subset in P], s, [set()])
print(ps(s)) # Output: [set(), {1}, {2}, {1, 2}, {3}, {1, 3}, {2, 3}, {1, 2, 3}]
'''
How it Works?
The idea of this one-liner is to start the powerset as an empty
set and repeatedly add subsets to it, until no more subsets
can be found.
'''