print a ... z, A ... Z, "\n"' in Python

js ebgssth at gmail.com
Sat Mar 3 03:07:43 EST 2007


HI guys,

How do you write Perl's

    print a ... z, A ... Z,  "\n"' in Python


In Python?


A way I came up with is the following, but I'm sure this is ugly.

    ''.join(chr(c) for c in (range(ord('a'), ord('z')+1) +
range(ord('A'), ord('Z')+1)))
or
    crange = lambda c1, c2: [ chr(c) for c in range(ord(c1), ord(c2)+1) ]
    ''.join(chr(c) for c in crange('a', 'z') + crange('A', 'Z'))


I want to feel The Zen of Python :)



More information about the Python-list mailing list