Lambda may not be necessary
195
196 if recipient_data["receive_limit_reached"] and not force:
197 remaining_time = cooldown_period - (now - last_received)
198 hours, minutes, seconds = map(lambda x: int(x), [remaining_time.seconds//3600, remaining_time.seconds % 3600//60, remaining_time.seconds % 60])199 await interaction.followup.send(
200 embed=Embeds.message(
201 title=lang[await get_guild_language(interaction.guild.id)][
Description
A lambda that calls a function without modifying any of its parameters is unnecessary. Python functions are first-class objects and can be passed around in the same way as the resulting lambda. It is recommended to remove the lambda and use the function directly.
It is preferred to use the function hash
directly as the lambda function calls the same function without any modifications.
Another reason to avoid the lambda function here is that it makes debugging difficult.
Lambdas show as <lambda>
in tracebacks, where functions will display the function’s name.
Bad practice
items = [1, 2, 3]
hashify = lambda x: hash(x)
hashed_items = map(hashify, items)
Recommended
items = [1, 2, 3]
# pass the builtin `hash` instead of the wrapper `hashify`
hashed_items = map(hash, items)