X Tutup
Skip to content

Commit 4aef41f

Browse files
committed
Remove import string and use string methods
1 parent 4737b23 commit 4aef41f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Doc/howto/sorting.tex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,10 @@ \section{Sorting basic data types}
110110
Here's a case-insensitive string comparison using a \keyword{lambda} function:
111111

112112
\begin{verbatim}
113-
>>> import string
114-
>>> a = string.split("This is a test string from Andrew.")
115-
>>> a.sort(lambda x, y: cmp(string.lower(x), string.lower(y)))
113+
>>> a = "This is a test string from Andrew".split()
114+
>>> a.sort(lambda x, y: cmp(x.lower(), y.lower()))
116115
>>> print a
117-
['a', 'Andrew.', 'from', 'is', 'string', 'test', 'This']
116+
['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']
118117
\end{verbatim}
119118

120119
This goes through the overhead of converting a word to lower case

0 commit comments

Comments
 (0)
X Tutup