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

2007-03-03 Thread Alex Martelli
rzed <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Alex Martelli) wrote in > news:[EMAIL PROTECTED]: > > > js <[EMAIL PROTECTED]> wrote: > > > >> HI guys, > >> > >> How do you write Perl's > >> > >> pr

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

2007-03-03 Thread rzed
[EMAIL PROTECTED] (Alex Martelli) wrote in news:[EMAIL PROTECTED]: > js <[EMAIL PROTECTED]> wrote: > >> HI guys, >> >> How do you write Perl's >> >> print a ... z, A ... Z, "\n"' in Python >> >> In Python? &

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

2007-03-03 Thread Alex Martelli
js <[EMAIL PROTECTED]> wrote: > I forgot to cc pythonlist... > # > > Thanks for you quick reply. > > I didn't know any string constants. > > >From Python Library reference, 4.1.1 String constants: > > letters >The concatenation of the strings lowercase and uppercase de

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

2007-03-03 Thread Alex Martelli
js <[EMAIL PROTECTED]> wrote: > HI guys, > > How do you write Perl's > > print a ... z, A ... Z, "\n"' in Python > > In Python? This specific one is easy, though this doesn't generalize: import string print string.lowercase + strin

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

2007-03-03 Thread js
> > Maybe we don't want char range If string constants would be rich > > enough. > > But as soon as we want a string that doesn't correspond to any > pre-defined constants, we're hosed. For example, there isn't > a constant that would correspond to this Perl-ism: > > print l ... w, e ... j, L ..

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

2007-03-03 Thread Lloyd Zusman
"js " <[EMAIL PROTECTED]> writes: >> But note that you return the last item of the range too, and that >> goes against the semantic of the usual Python range/xrange, so you >> may want to call this function with another name. > > That makes sense. 100% agree with you. > >> Maybe there are better w

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

2007-03-03 Thread MonkeeSage
js wrote: > A way I came up with is the following, but I'm sure this is ugly. You could abuse __getitem__ (terribly, heh!) and use slice syntax... class crange(): def __init__(self): self.valid = range(47,58) + range(65,91) + range(97,123) def __getitem__(self, s): if is

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

2007-03-03 Thread js
I forgot to cc pythonlist... # Thanks for you quick reply. I didn't know any string constants. >From Python Library reference, 4.1.1 String constants: letters The concatenation of the strings lowercase and uppercase described below. The specific value is locale-dependen

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

2007-03-03 Thread js
> But note that you return the last item of the range too, and that goes > against the semantic of the usual Python range/xrange, so you may want > to call this function with another name. That makes sense. 100% agree with you. > Maybe there are better ways to solve this problem. Maybe a way to >

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

2007-03-03 Thread bearophileHUGS
js: > 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')) Yes, managing char ranges is a bit of pain with Python. You can also pack those chars: xcrange = lambda cc: (chr(c) for c in xrange(ord(cc[0]), ord(cc[1]) +1)

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

2007-03-03 Thread Troy Melhase
> How do you write Perl's > > print a ... z, A ... Z, "\n"' in Python > > > In Python? you might consider this cheating, but it's packed with zen goodness: >>> import string >>> print string.letters abcdefghijklmnopqrstuvwxyz

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

2007-03-03 Thread js
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&#x