diff options
author | Adam Brenecki <adam@brenecki.id.au> | 2013-09-20 19:32:58 +0930 |
---|---|---|
committer | Adam Brenecki <adam@brenecki.id.au> | 2013-09-20 19:32:58 +0930 |
commit | 1405dc6387ad95f0161e788a27340e02f3f82471 (patch) | |
tree | 308e08801b6390e91163831da552adb330f2d298 /python.html.markdown | |
parent | 750b2a2f21262fc011d5ee07362c667223d3de23 (diff) |
[python] Clarify setdefault, as per #234
Diffstat (limited to 'python.html.markdown')
-rw-r--r-- | python.html.markdown | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/python.html.markdown b/python.html.markdown index bad9a360..bbb493da 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -224,7 +224,7 @@ filled_dict.get("four") #=> None filled_dict.get("one", 4) #=> 1 filled_dict.get("four", 4) #=> 4 -# "setdefault()" method is a safe way to add new key-value pair into dictionary +# "setdefault()" inserts into a dictionary only if the given key isn't present filled_dict.setdefault("five", 5) #filled_dict["five"] is set to 5 filled_dict.setdefault("five", 6) #filled_dict["five"] is still 5 @@ -282,9 +282,9 @@ prints: for animal in ["dog", "cat", "mouse"]: # You can use % to interpolate formatted strings print "%s is a mammal" % animal - + """ -"range(number)" returns a list of numbers +"range(number)" returns a list of numbers from zero to the given number prints: 0 @@ -459,7 +459,7 @@ import math as m math.sqrt(16) == m.sqrt(16) #=> True # Python modules are just ordinary python files. You -# can write your own, and import them. The name of the +# can write your own, and import them. The name of the # module is the same as the name of the file. # You can find out which functions and attributes |