View on GitHub

Tristan Hill

Blog about IT related stuff

Is this good or bad python code?

A recursive generator:

#!/usr/bin/python3
import string
import itertools

def letter_count():
    prefix = ''
    prefix_generator = letter_count()
    while True:
        for l in string.ascii_lowercase:
            yield prefix + l
        prefix = next(prefix_generator)

if __name__ == '__main__':
    for l in letter_count():
        print(l)