Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c26467d

Browse files
committed
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.
1 parent 9635d0b commit c26467d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Doc/tut/tut.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,9 @@ \subsection{Keyword Arguments \label{keywordArgs}}
14851485
print "-- I'm sorry, we're all out of", kind
14861486
for arg in arguments: print arg
14871487
print '-'*40
1488-
for kw in keywords.keys(): print kw, ':', keywords[kw]
1488+
keys = keywords.keys()
1489+
keys.sort()
1490+
for kw in keys: print kw, ':', keywords[kw]
14891491
\end{verbatim}
14901492

14911493
It could be called like this:
@@ -1511,6 +1513,11 @@ \subsection{Keyword Arguments \label{keywordArgs}}
15111513
sketch : Cheese Shop Sketch
15121514
\end{verbatim}
15131515

1516+
Note that the \method{sort()} method of the list of keyword argument
1517+
names is called before printing the contents of the \code{keywords}
1518+
dictionary; if this is not done, the order in which the arguments are
1519+
printed is undefined.
1520+
15141521

15151522
\subsection{Arbitrary Argument Lists \label{arbitraryArgs}}
15161523

0 commit comments

Comments
 (0)