r/pygame • • May 03 '14

Python Descriptors/Properties Demystified

http://nbviewer.ipython.org/urls/gist.github.com/ChrisBeaumont/5758381/raw/descriptor_writeup.ipynb
4 Upvotes

2 comments sorted by

2

u/dr3d3d May 03 '14

I had a huge issue understanding why I might want to use properties... most "descriptions" said something along the lines of so you don't need to use Getters/Setters... the immediate question is then of course why would I need Getters/Setters lol

Anyhow this article covers all that and Describes it perfectly so thought id share

1

u/MonkeyNin May 28 '14

one advantage is you can start your code with an attribute. Later 'upgrade' to a property, if you need getters/setters. Other languages this would require external code to change.