[Python-checkins] commit of r41485 - python/trunk/Doc/howto
neal.norwitz@python.org
neal.norwitz at python.org
Sun Nov 20 01:24:18 CET 2005
Author: neal.norwitz
Date: Sun Nov 20 01:24:18 2005
New Revision: 41485
Modified:
python/trunk/Doc/howto/sorting.tex
Log:
Remove import string and use string methods
Modified: python/trunk/Doc/howto/sorting.tex
==============================================================================
--- python/trunk/Doc/howto/sorting.tex (original)
+++ python/trunk/Doc/howto/sorting.tex Sun Nov 20 01:24:18 2005
@@ -110,11 +110,10 @@
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
More information about the Python-checkins
mailing list