1184 bot.send_message(
1185 chat_id=chat_id,
1186 reply_to_message_id=reply_to_message_id,
1187 text="*Sorry*, not enough memory to convert file `{}`..".format(file_name),1188 parse_mode="Markdown",
1189 )
1190 )
1194 bot.send_message(
1195 chat_id=chat_id,
1196 reply_to_message_id=reply_to_message_id,
1197 text="*Sorry*, not enough memory to convert file `{}`..".format(file_name),1198 parse_mode="Markdown",
1199 )
1200 )
1136 part_size = file_size // parts_number
1137 cur_position = 0
1138 for i in range(parts_number):
1139 file_part = file.replace(file_ext, ".part{}{}".format(str(i + 1), file_ext))1140 ffinput = ffmpeg.input(file)
1141 if i == (parts_number - 1):
1142 ffmpeg.output(ffinput, file_part, codec="copy", vn=None, ss=cur_position).run()
1171 bot.send_message(
1172 chat_id=chat_id,
1173 reply_to_message_id=reply_to_message_id,
1174 text="*Sorry*, downloaded file `{}` is `{}` MB and it is larger than I could convert (`{} MB`)".format(1175 file_name, exc.file_size // 1000000, MAX_CONVERT_FILE_SIZE // 1000000
1176 ),
1177 parse_mode="Markdown",
1318 bot.send_message(
1319 chat_id=chat_id,
1320 reply_to_message_id=reply_to_message_id,
1321 text="*Sorry*, could not send file `{}` or some of it's parts..".format(file_name),1322 parse_mode="Markdown",
1323 )
1324 )
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} ¤"