"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
<[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(
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
"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
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
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
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)
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
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