generating a liste of characters

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Dec 5 08:16:48 EST 2008


Mark Tolonen:
> Writing a helper function reduces code repetition and improves readability:
>     def crange(startch,endch):
>         '''Return a list of characters from startch to endch, inclusive.'''
>         return [chr(c) for c in xrange(ord(startch),ord(endch)+1)]

In Python ranges are open on the right, so I name cinterval such
function.

Bye,
bearophile



More information about the Python-list mailing list