Re: generating a liste of characters

2008-12-05 Thread Duncan Booth
"Mark Tolonen" <[EMAIL PROTECTED]> wrote: ><[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > .. >>In Python ranges are open on the right, so I name cinterval such >>function. > > Yes, and that's fine when dealing with integers and slicing, but when > dealing with characters, it i

Re: generating a liste of characters

2008-12-05 Thread Mark Tolonen
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] 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(

Re: generating a liste of characters

2008-12-05 Thread bearophileHUGS
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

Re: generating a liste of characters

2008-12-05 Thread Mark Tolonen
"Yves Dorfsman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Is there any built in way to generate a list of characters, something along the line of range('a'-'z') ? Right now I am using: chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 chars += [ chr(l) for l in rang

Re: generating a liste of characters

2008-12-04 Thread Matt Nordhoff
This is a slightly old post, but oh well... Shane Geiger wrote: > import string > alphabet=list(string.letters[0:26]) > print alphabet Most of the string module's constants are locale-specific. If you want the ASCII alphabet instead of the current language's, you need to use string.ascii_{letters

Re: generating a liste of characters

2008-12-03 Thread Vlastimil Brom
2008/12/3 Yves Dorfsman <[EMAIL PROTECTED]>: > Is there any built in way to generate a list of characters, something > along the line of range('a'-'z') ? > > Right now I am using: > > chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 > chars += [ chr(l) for l in range(0x41, 0x5b) ] # A - Z

Re: generating a liste of characters

2008-12-03 Thread Shane Geiger
import string alphabet=list(string.letters[0:26]) print alphabet Yves Dorfsman wrote: Is there any built in way to generate a list of characters, something along the line of range('a'-'z') ? Right now I am using: chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 chars += [ chr(l)

Re: generating a liste of characters

2008-12-03 Thread James Mills
On Thu, Dec 4, 2008 at 12:18 AM, Yves Dorfsman <[EMAIL PROTECTED]> wrote: > Is there any built in way to generate a list of characters, something > along the line of range('a'-'z') ? > > Right now I am using: > > chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 > chars += [ chr(l) for l i

generating a liste of characters

2008-12-03 Thread Yves Dorfsman
Is there any built in way to generate a list of characters, something along the line of range('a'-'z') ? Right now I am using: chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 chars += [ chr(l) for l in range(0x41, 0x5b) ] # A - Z chars += [ chr(l) for l in range(0x61, 0x7b) ] # a