SK
>>> def d(z):
... del z[1]
>>> print(l)
[3, 2, 1]
>>> d(l)
>>> print(l)
[3, 1]
Size: a a a
SK
ЕД
SK
DS
SK
SK
DS
DS
def end_conversation_handler(update: Update, context: CallbackContext):
if not config.cancel_r.match(update.message.text):
update = None # If not none - user will be notified.
if 'user' in context.user_data:
return bot.end_conversation(update=update, objects_to_del=[context.user_data['user']])
elif 'TargetUser' in context.user_data:
return bot.end_conversation(update=update, objects_to_del=[context.user_data['TargetUser']])
elif 'Post' in context.user_data:
return bot.end_conversation(update=update, objects_to_del=[context.user_data['Post']])
def end_conversation(objects_to_del: list = None, update: Update = None, context=None) -> int:
if update:
update.message.reply_text(text='Галя, неси ключ, у нас отмена! Отменено.',
reply_markup=tg_ReplyKeyboardRemove())
for i in objects_to_del:
del object_to_del # Not working!
return -1
DS
DS
ЕД
ЕД
ЕД
SK
context.user_data['Post']
context.user_data['Post']
[блабла]DS
SK
object_to_del
из списка context.user_data['Post']
object_to_del
, ты удаляешь по одной ссылке из двух. то есть, в context.user_data['Post']
ничего не пропадёт и сами объекты тоже там не пропадут. ты же копию списка сделал и потом удалил... копию.DS
SK
object_to_del
:context.user_data['Post']
[d]SK