Skip to content

Commit 5519ac8

Browse files
Fixed #4: string formatting
1 parent 589dbfa commit 5519ac8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/correctness/method_could_be_a_function.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ All class methods must be preceded by the ``@classmethod`` decorator. Furthermor
6666
class Rectangle:
6767
@classmethod
6868
def print_class_name(cls):
69-
print("class name: %s" % cls) # "class name: Rectangle"
69+
print("class name: {0}".format(cls)) # "class name: Rectangle"
7070
7171
References
7272
----------

docs/correctness/method_has_no_argument.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The method ``print_class_name`` attempts to print the name of the class. However
2828
class Rectangle:
2929
@classmethod
3030
def print_class_name(): # missing first argument "cls"
31-
print("Hello, I am %s!" % cls) # cls is undefined here
31+
print("Hello, I am {0}!".format(cls)) # cls is undefined here
3232
3333
3434
The method ``area`` computes the value of any rectangle. Currently this method is ambiguous. It is defined as a method of the ``Rectangle`` class, yet it does not reference any instance or class members. The method needs to explicitly state that it is a static method via the ``@staticmethod`` decorator.
@@ -68,7 +68,7 @@ To access the name of the class the ``print_class_name`` method needs to explici
6868
class Rectangle:
6969
@classmethod
7070
def print_class_name(cls): # class members now accessible, thanks to "cls"
71-
print("Hello, I am %s!" % cls)
71+
print("Hello, I am {0}!".format(cls))
7272
7373
Add the ``@staticmethod`` decorator to static methods
7474
........................................................

0 commit comments

Comments
 (0)