[Pythonjp-checkins] [python-doc-ja] push by songo****@gmail***** - Update 2.7.2: tutorial/controlflow.rst on 2011-10-30 10:46 GMT

Back to archive index

pytho****@googl***** pytho****@googl*****
2011年 10月 30日 (日) 19:50:09 JST


Revision: f5f5df2003b6
Author:   Naoki INADA  <inada****@klab*****>
Date:     Sun Oct 30 03:46:46 2011
Log:      Update 2.7.2: tutorial/controlflow.rst
http://code.google.com/p/python-doc-ja/source/detail?r=f5f5df2003b6

Modified:
  /tutorial/controlflow.rst

=======================================
--- /tutorial/controlflow.rst	Fri May 13 06:42:55 2011
+++ /tutorial/controlflow.rst	Sun Oct 30 03:46:46 2011
@@ -451,11 +451,12 @@
     def cheeseshop(kind, *arguments, **keywords):
         print "-- Do you have any", kind, "?"
         print "-- I'm sorry, we're all out of", kind
-       for arg in arguments: print arg
+       for arg in arguments:
+           print arg
         print "-" * 40
-       keys = keywords.keys()
-       keys.sort()
-       for kw in keys: print kw, ":", keywords[kw]
+       keys = sorted(keywords.keys())
+       for kw in keys:
+           print kw, ":", keywords[kw]

  呼び出しは以下のようになり、

@@ -480,8 +481,8 @@
     shopkeeper : Michael Palin
     sketch : Cheese Shop Sketch

-キーワード引数名のリストに対して :meth:`sort` を呼び出した後に ``keywords``
-辞書の内容を出力していることに注意してください。
+キーワード引数名のリストを、キーワード辞書の ``keys()`` メソッドの結果を
+ソートして作成していることに注目してください。
  :meth:`sort` が呼び出されていないと、引数が出力される順番は不確定となりま 
す。




Pythonjp-checkins メーリングリストの案内
Back to archive index