summaryrefslogtreecommitdiffhomepage
path: root/python.html.markdown
diff options
context:
space:
mode:
authorAdam <adam@adambard.com>2013-06-28 21:20:08 -0700
committerAdam <adam@adambard.com>2013-06-28 21:20:08 -0700
commita6bcf5f8d7fe60af918eea947bee7f5950a2061d (patch)
tree6ef6b011ab87cf2ee2bc911f5a965cc25314fcd6 /python.html.markdown
parent4789dd1097ea3980374715eaac7852552d2fa036 (diff)
Fixes #16: Added new-style string formatting
Diffstat (limited to 'python.html.markdown')
-rw-r--r--python.html.markdown7
1 files changed, 7 insertions, 0 deletions
diff --git a/python.html.markdown b/python.html.markdown
index 3127cf2e..463556d9 100644
--- a/python.html.markdown
+++ b/python.html.markdown
@@ -80,6 +80,13 @@ not False #=> True
# A string can be treated like a list of characters
"This is a string"[0] #=> 'T'
+# % can be used to format strings, like this:
+"%s can be %s" % ("strings", "interpolated")
+
+# A newer way to format strings is the format method.
+# This method is the preferred way
+"{0} can be {1}".format("strings", "formatted")
+
# None is an object
None #=> None