from string import digits, ascii_uppercase, ascii_lowercase
from itertools import product
chars = digits + ascii_uppercase + ascii_lowercase
for n in range(1, 4 + 1):
    for comb in product(chars, repeat=n):
        pass
Generate alphanumeric strings sequentially