WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Discussion options

You must be logged in to vote

It's a style preference. I prefer your first form since it's clear which entity you are referring to. I don't think the 2nd form helps much since you refer to robot_entity an equal number of times, and a reader (like me) unfamiliar with the code would have to take the additional step of looking for the value of robot_entity. It's also slightly confusing since if you later change robot_entity to a different value, the previously defined triggers won't change since the decorator's arguments are evaluated once when the function is defined, but the value of robot_entity in the function body will reflect the new value when the function is called. So that could create subtle bugs that would be …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andarotajo
Comment options

Answer selected by andarotajo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants