How can I write a Python generator that lazily generates all strings composed of lowercase English letters of up to a certain length1?
I have written my own solution (posted below as an answer), but I would like to see if there are any more elegant/efficient/fun solutions out there.
1 An infinite iterator would be pretty useless because it would just generate strings composed of only the character a. This is because the lexicographical ordering of strings is not a well-order; it can be thought of as composed of an infinite sequence of infinitely nested sequences: (a, (aa, ...), (ab, ...), ...), (b, (ba, ...), (bb, ...), ...), ... The generator would never reach ab since it has an infinite amount of predecessors.