from itertools import combinations

def generate_vertices(n):
    for number_of_ones in range(0, n + 1):
        for location_of_ones in combinations(range(0, n), number_of_ones):
            result = [0] * n
for location in location_of_ones:
    result[location] = 1
yield result
for vertex in generate_vertices(3):
    pass
Permutations with repetition in Python