Dan Sommers wrote: > On Fri, 27 May 2005 16:10:32 +0200, > Wolfram Kraus <[EMAIL PROTECTED]> wrote: > > >>Duncan Booth wrote: > > >>>>>>import string >>>>>>upone = string.maketrans( >>> >>>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', >>>'bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA') >>> >>> >>>>>>string.translate("I've got a string s....", upone) > > >>Wow, that's quite nice. You really learn something new every day :-) A >>minor improvement: Use string.ascii_letters as the first parameter for >>string.maketrans > > > And use string.ascii_letters[ 1 : ] + string.ascii_letters[ 0 ] for the > second parameter to string.maketrans. >
Not quite: >>> string.ascii_letters[ 1 : ] + string.ascii_letters[ 0 ] 'bcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZa' i.e. you get 'z' -> 'A' and 'Z' -> 'a' Another issue is locale settings and special characters - what should be done with accented letters? Preserve letter, or shift and loose accent? -- http://mail.python.org/mailman/listinfo/python-list