def chunks(s, n):
    """Produce `n`-character chunks from `s`."""
for start in range(0, len(s), n):
    yield s[start:start + n]
chars = 'ATGAAATAA'
for chunk in chunks(chars, 3):
    pass
Using Python regular expressions to split on non-overlapping character groups (ORF finding)