73 @staticmethod
74 def setup_error(k: str):
75 logger.error(
76 '.env file is not correctly set up! Missing key {}'.format(k))77 exit(1)
78
79
68 @staticmethod
69 def setup_warning(k: str):
70 logger.warn(
71 '.env file does not have key {}. Some features may not function as intended.'.format(k))72
73 @staticmethod
74 def setup_error(k: str):
194 self.stream_url = data.get('url')
195
196 def __str__(self):
197 return '**{0.title}** by **{0.uploader}**'.format(self) 198
199 @classmethod
200 async def create_source(self, ctx, search: str, *, loop: asyncio.BaseEventLoop = None, requester=None, seek=None):
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} ¤"