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
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.
The text was updated successfully, but these errors were encountered:
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().
Just curious about https://github.com/exercism/python/blob/master/exercises/hangman/hangman_test.py -
remaining_guesses
is accessed directly (implying it is either aproperty
or an instance variable) whereas there is aget_status()
andget_masked_word()
, getter instance methods.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.
The text was updated successfully, but these errors were encountered: