#NEWLINE# def powerset( iterable ) : #NEWLINE# #INDENT# "powerset('abc') -> a b c ab ac bc abc" #NEWLINE# s = list ( iterable ) #NEWLINE# for chars in itertools . chain . from_iterable ( ( itertools . combinations ( chars , r ) for r in range ( 1 , ( len ( s ) + 1 ) ) ) ) : #NEWLINE# #INDENT# ( yield '' . join ( chars ) )