x = 'abcd'
while True:
print(x)
x = inc(x)
def gen(start, alphabet, end=None):
if start != end:
end = end or start
yield start
value = inc(start, alphabet)
while value != end:
yield value
value = inc(start, alphabet)
for x in gen('aabb', 'abcd'):
print(x)
# напечатает все коды от 'aabb', 'aabc', 'aabd', ... 'dddd', 'aaaa', 'aaab' и до 'aaba'