824 raise ValueError("Project `%s` could not be found." % str(project))
825
826 projectVersions = cls.get(
827 "/projects/{}/projectVersions".format(project_info.id)828 )
829 versionList = []
830 try:
821 project_info = cls.get_project(project)
822
823 if project_info is None:
824 raise ValueError("Project `%s` could not be found." % str(project))825
826 projectVersions = cls.get(
827 "/projects/{}/projectVersions".format(project_info.id)
795 model = cls.get_model(model)
796 id_ = model["id"]
797
798 return cls.get("/models/%s" % id_)799
800 @classmethod
801 def list_project_versions(cls, project):
764 content = "application/json"
765
766 return cls.put(
767 "/models/%s/typeConversion" % id_,768 headers={"Accept-Item": accept, "Content-Type": content, "If-Match": ETag},
769 )
770
715 headers={"Accept": "application/json"},
716 )
717 if not response:
718 warn("No score resources found for model '{}'".format(model_obj.name))719 return response
720 except HTTPError as e:
721 if e.code == 406:
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} ¤"