From: Neal Norwitz Date: Sun, 20 Nov 2005 00:24:18 +0000 (+0000) Subject: Remove import string and use string methods X-Git-Tag: v2.5a0~1143 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4aef41ffe7bee84f3b6440f4d76099cd030d058b;p=thirdparty%2FPython%2Fcpython.git Remove import string and use string methods --- diff --git a/Doc/howto/sorting.tex b/Doc/howto/sorting.tex index a849c665e048..37a7033ceab1 100644 --- a/Doc/howto/sorting.tex +++ b/Doc/howto/sorting.tex @@ -110,11 +110,10 @@ types, do the forward sort first, then use the \method{reverse()} method. Here's a case-insensitive string comparison using a \keyword{lambda} function: \begin{verbatim} ->>> import string ->>> a = string.split("This is a test string from Andrew.") ->>> a.sort(lambda x, y: cmp(string.lower(x), string.lower(y))) +>>> a = "This is a test string from Andrew".split() +>>> a.sort(lambda x, y: cmp(x.lower(), y.lower())) >>> print a -['a', 'Andrew.', 'from', 'is', 'string', 'test', 'This'] +['a', 'Andrew', 'from', 'is', 'string', 'test', 'This'] \end{verbatim} This goes through the overhead of converting a word to lower case