The Python Oracle

How to Use Getter Without Setter

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Book End

--

Chapters
00:00 How To Use Getter Without Setter
00:52 Accepted Answer Score 7
01:06 Thank you

--

Full question
https://stackoverflow.com/questions/4186...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #python27 #properties #python2x #gettersetter

#avk47



ACCEPTED ANSWER

Score 7


You'll need to inherit from object for properties to work properly.

class Test(object):
    ...

That's because properties are implemented with descriptors and only new-style classes support descriptors.