[Tutor] range()-like function to generate aa, ... az, ..., zz ?

ZIYAD A. M. AL-BATLY zamb at saudi.net.sa
Thu Jul 28 20:40:45 CEST 2005


On Thu, 2005-07-28 at 13:59 -0400, Chris Shenton wrote:
> I'm looking for a range()-like function which could generate a list of
> character-oriented tokens, like to iterate over all two-character
> sequences like:
> 
>  pseudorange('aa', 'zz') would generate:
>   aa, ab, ..., az, ba, ..., za, ..., zz
> 
> range() doesn't do character iteration, and I'm sure I could write  a
> dumb function to do it, but was wondering if there was something more
> generic -- e.g., later I might want
> 
>  pseudorange('aaa', 'mmm')
> 
> Anyway, is there a function to iterate through a range of character
> strings similar to this? 
> 
> Thanks.
My small controbution to PyTuyo:
  >>> twoLetterSequence  = [ "%c%c" % (x, y) for x in range(ord('a'), ord('z')+1) for y in range(ord('a'), ord('z')+1)]

Ziyad.


More information about the Tutor mailing list