36 "bb": {"emoji": "🏀", "help": "The special basketball emoji"},
37 "soccer": {"emoji": "⚽️", "help": "The special football emoji"},
38}
39special_emoji_commands = [x for x in special_emojis_dict]40
41
42@UserBot.on_message(filters.command(special_emoji_commands, ".") & filters.me)
15 "earth": list("🌏🌍🌎🌎🌍🌏🌍🌎"),
16 "heart": list("❤️🧡💛💚💙💜🖤"),
17}
18emoji_commands = [x for x in emojis]19
20
21@UserBot.on_message(filters.command(emoji_commands, ".") & filters.me)
It is unnecessary to use a comprehension just to loop over the iterable
and create a list
/set
/dict
out of it.
Python has a specialized set of tools for this task: the list
/set
/dict
constructors, which are faster and more readable.
states = [
('AL', 'Alabama'),
('AK', 'Alaska'),
('AZ', 'Arizona'),
('AR', 'Arkansas'),
('CA', 'California'),
# ...
]
abbreviations_to_names = {
abbreviation: name
for abbreviation, name in states
}
states = [
('AL', 'Alabama'),
('AK', 'Alaska'),
('AZ', 'Arizona'),
('AR', 'Arkansas'),
('CA', 'California'),
# ...
]
abbreviations_to_names = dict(states)