@@ -48,8 +48,8 @@ def _json_dict(json):
4848 elif isinstance (json , string_types ):
4949 return json_pkg .loads (json )
5050 else :
51- error = "'json' must be a dictionary or string; " \
52- "received: %r" % json
51+ error = "'json' must be a dictionary or JSON string; " \
52+ "received: {!r}" . format ( json )
5353 raise TypeError (error )
5454
5555
@@ -96,19 +96,19 @@ def __getattr__(self, item):
9696 else :
9797 return item_data
9898 else :
99- error = "'%s ' object has no attribute '%s'" % \
100- (self .__class__ .__name__ , item )
99+ error = "'{} ' object has no attribute " \
100+ "'{}'" . format (self .__class__ .__name__ , item )
101101 raise AttributeError (error )
102102
103103 def __str__ (self ):
104104 """Return a human-readable string representation of this object."""
105105 class_str = self .__class__ .__name__
106106 json_str = json_pkg .dumps (self ._json , indent = 2 )
107- return "%s :\n %s" % (class_str , json_str )
107+ return "{} :\n {}" . format (class_str , json_str )
108108
109109 def __repr__ (self ):
110110 """Return a string representing this object as valid Python expression.
111111 """
112112 class_str = self .__class__ .__name__
113113 json_str = json_pkg .dumps (self ._json , ensure_ascii = False )
114- return "%s(%r)" % (class_str , json_str )
114+ return "{}({})" . format (class_str , json_str )
0 commit comments