82 params = locals()
83 for key, val in six.iteritems(params["kwargs"]):
84 if key not in all_params:
85 raise TypeError("Got an unexpected keyword argument '%s'" " to method search" % key) 86 params[key] = val
87 del params["kwargs"]
88 # verify the required parameter 'q' is set
197 params = locals()
198 for key, val in six.iteritems(params["kwargs"]):
199 if key not in all_params:
200 raise TypeError("Got an unexpected keyword argument '%s'" " to method get_gc" % key)201 params[key] = val
202 del params["kwargs"]
203 # verify the required parameter 'gc_id' is set
246 :return: The report for debugging.
247 """
248 return (
249 "Python SDK Debug Report:\n"250 "OS: {env}\n"
251 "Python Version: {pyversion}\n"
252 "Version of the API: 2.0\n"
648 return string
649 except ValueError:
650 raise rest.ApiException(
651 status=0, reason=("Failed to parse `{0}` as datetime object".format(string))652 )
653
654 def __hasattr(self, object, name):
629 return string
630 except ValueError:
631 raise rest.ApiException(
632 status=0, reason="Failed to parse `{0}` as date object".format(string)633 )
634
635 def __deserialize_datatime(self, string):
f-strings are the fastest way to format strings as compared to the following methods:
%
format()
str.join
+
operator to concatinate stringTemplate.substitute
Some less preferred ways to format strings are the following:
from string import Template
menu = ('eggs', 'spam', 42.4)
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + " and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = " and ".join(menu[:2])
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2])
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2])
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])
Consider using f-strings as shown below:
menu = ('eggs', 'spam', 42.4)
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"