On Mon, 13 Feb 2006 19:03:32 +0000 in comp.lang.python, rtilley <[EMAIL PROTECTED]> wrote:
>Dave Hansen wrote: >> How about >> >> s = "some random string" >> print s >> s = s[::-1] >> print s > >That looks like Perl, but it works. Makes me wonder with the string >module doesn't have a reverse or invert function? It's just simple slicing. Well, maybe not so simple, or at least not so common, but with a syntax similar to the range function. Consider the following (string chosen to make it obvious what's going on): s = "0123456789" s[::] s[3::] s[:3:] s[::3] s[::-2] s[-2::-2] Regards, -=Dave -- Change is inevitable, progress is not. -- http://mail.python.org/mailman/listinfo/python-list