38 return
39
40 try:
41 await message.edit("```Making a Quote\nProcessing {}%```".format(progress))42 except:
43 await message.edit("ERROR")
44
7from userbot import UserBot
8from userbot.plugins.help import add_command_help
9
10mention = partial("<a href='tg://user?id={}'>{}</a>".format)11
12hmention = partial("<a href='tg://user?id={}'>\u200B</a>{}".format)
13
66 else:
67 evaluation = "Success"
68
69 final_output = "<b>Expression</b>:\n<code>{}</code>\n\n<b>Result</b>:\n<code>{}</code> \n".format( 70 cmd, evaluation.strip()
71 )
72
53 return
54
55 CARBON_LANG = type_text
56 await message.edit_text("Carbon type set to {}".format(type_text))57 await sleep(2)
58 await message.delete()
59
25
26 await message.edit_text("Carbonizing code...")
27 # Do the thing
28 os.system("carbon-now -h -t userbot/downloads/carbon {}".format(file))29 # await message.edit_text("Carbonizing completed...")
30 # Send the thing
31 await bot.send_photo(message.chat.id, "userbot/downloads/carbon.png")
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} ¤"