diff options
| author | Ian Bertolacci <ian.bertolacci@gmail.com> | 2015-07-18 14:10:01 -0700 | 
|---|---|---|
| committer | Ian Bertolacci <ian.bertolacci@gmail.com> | 2015-07-18 14:10:01 -0700 | 
| commit | 3ca94ec6ac5adb9bb8d30c2e2eaa86d40c5cb989 (patch) | |
| tree | 0f66402916a3e71456fb5b332844629e69a072f9 /python.html.markdown | |
| parent | 6a54bca6ee74486b6eddadec17b6fc7f0c8bf43b (diff) | |
| parent | 71f87d44fd4aae061e0c9d1b52a202a1be4fc332 (diff) | |
Merged down
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 b89fe57d..3b233f7f 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -327,8 +327,8 @@ prints:      mouse is a mammal  """  for animal in ["dog", "cat", "mouse"]: -    # You can use % to interpolate formatted strings -    print "%s is a mammal" % animal +    # You can use {0} to interpolate formatted strings. (See above.) +    print "{0} is a mammal".format(animal)  """  "range(number)" returns a list of numbers @@ -387,7 +387,7 @@ else:   # Optional clause to the try/except block. Must follow all except blocks  # Use "def" to create new functions  def add(x, y): -    print "x is %s and y is %s" % (x, y) +    print "x is {0} and y is {1}".format(x, y)      return x + y    # Return values with a return statement  # Calling functions with parameters @@ -497,7 +497,7 @@ class Human(object):      # An instance method. All methods take "self" as the first argument      def say(self, msg): -        return "%s: %s" % (self.name, msg) +        return "{0}: {1}".format(self.name, msg)      # A class method is shared among all instances      # They are called with the calling class as the first argument | 
