You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hangman: Wondering why remaining_guesses vs get_status() #1910
Since I am not very familiar with Python conventions I don't have a good sense of when someone should use property vs getter instance method. Any explanation available for this exercise as to why the respective choices were taken? Thank you.
Since that is the course of action and this issue does not appear to need maintainer action, let me close it to get it out of the track's issue queue. Explanations are still welcomed of course even after it is closed.
If an accessor function would be trivial, you should use public variables instead of accessor functions to avoid the extra cost of function calls in Python. When more functionality is added you can use property to keep the syntax consistent.
On the other hand, if access is more complex, or the cost of accessing the variable is significant, you should use function calls (following the Naming guidelines) such as get_foo() and set_foo().
Activity
cmccandless commentedon Sep 9, 2019
It wasn't specifically called out in the implementing PR (#1690) one way or the other.
If @junming403 is available for comment, that would be the only way to gain more insight.
petertseng commentedon Sep 10, 2019
Since that is the course of action and this issue does not appear to need maintainer action, let me close it to get it out of the track's issue queue. Explanations are still welcomed of course even after it is closed.
petertseng commentedon Sep 10, 2019
I turned to online style guides to answer the question in the issue, and found http://google.github.io/styleguide/pyguide.html#315-access-control
Now I understand.