простите за мой английский
'''
ALL_ITEMS : list : list of all items
screening : func : (keyboard) : screening keyboard from create_keyboard
create_keyboard : func : (*markup) : get rows(lists) of buttons
button : list : manually : ['<label>', after_click]
after_click : manually :
if : list : [func, call_for_func]
if : func : function, activated after clicking
'''
from random import choice
def create_item_buttons(item):
'''
:return: two rows of clickable buttons for item
'''
return [
[
[item.name, item.details]], # row 1
[
['option1', [print,'option1']], ['option2', [print,'option2']]]] # row 2
def create_empty_row():
'''
:return: one row of a non-clickable button
'''
return ['', [print,'IGNORE']]
get_item = lambda: choice([choice(ALL_ITEMS), None])
test_list_of_items = [get_item() for _ in range(5)]
test_markup = [*create_item_buttons(item)
if item # Error
else create_empty_row()
for item in test_list_of_items]
screening(create_keyboard(*markup))
итог:
if item
^
SyntaxError: invalid syntax