diff options
author | Fred Drake <fdrake@acm.org> | 2002-01-29 14:54:18 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-01-29 14:54:18 (GMT) |
commit | 0d55fc36e5db93834e7705acce45433ca0ecd865 (patch) | |
tree | be039d57a0493c3684d07920fa7f48ad177e8ebe /Doc/tut/tut.tex | |
parent | 7043010028ae15e3f23b2dc0516d39fd2a3e2359 (diff) | |
download | cpython-0d55fc36e5db93834e7705acce45433ca0ecd865.zip cpython-0d55fc36e5db93834e7705acce45433ca0ecd865.tar.gz cpython-0d55fc36e5db93834e7705acce45433ca0ecd865.tar.bz2 |
Revise cheeseshop example so that the order of the keyword output is
completely determined by the example; dict insertion order and the string
hash algorithm no longer affect the output.
This fixes SF bug #509281.
Diffstat (limited to 'Doc/tut/tut.tex')
-rw-r--r-- | Doc/tut/tut.tex | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index 608388b..27f33c9 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -1485,7 +1485,9 @@ def cheeseshop(kind, *arguments, **keywords): print "-- I'm sorry, we're all out of", kind for arg in arguments: print arg print '-'*40 - for kw in keywords.keys(): print kw, ':', keywords[kw] + keys = keywords.keys() + keys.sort() + for kw in keys: print kw, ':', keywords[kw] \end{verbatim} It could be called like this: @@ -1511,6 +1513,11 @@ shopkeeper : Michael Palin sketch : Cheese Shop Sketch \end{verbatim} +Note that the \method{sort()} method of the list of keyword argument +names is called before printing the contents of the \code{keywords} +dictionary; if this is not done, the order in which the arguments are +printed is undefined. + \subsection{Arbitrary Argument Lists \label{arbitraryArgs}} |