Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread eryk sun
On Wed, Apr 19, 2017 at 10:19 AM, Peter Otten <__pete...@web.de> wrote: > Steven D'Aprano wrote: > >> As I said, I haven't had a chance to try Peter's code, so it's possible >> that he's solved all these problems. I'm judging by previous > > No, my simple code only "works" for read-only properties

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread Alan Gauld via Tutor
On 19/04/17 08:43, Alan Gauld via Tutor wrote: > Probably because it is such a rare use case and because > its not that hard to do yourself if you really need it. Having read Steven's post I'll retract the bit about it being not that hard! :-) But I still think its a fairly rare scenario. Until

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread Peter Otten
Steven D'Aprano wrote: > As I said, I haven't had a chance to try Peter's code, so it's possible > that he's solved all these problems. I'm judging by previous No, my simple code only "works" for read-only properties and only as long as you don't overwrite the property by assigning to the attrib

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread Steven D'Aprano
On Wed, Apr 19, 2017 at 09:28:26AM +0200, Thomas Güttler wrote: [code for a classproperty] > Nice, if it is that simple. > > Is there a reason why this is not in the standard library? I haven't had a chance to test Peter's classproperty code yet, but I don't expect it to be that simple. People

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread Alan Gauld via Tutor
On 19/04/17 08:28, Thomas Güttler wrote: > Nice, if it is that simple. > > Is there a reason why this is not in the standard library? Probably because it is such a rare use case and because its not that hard to do yourself if you really need it. But the standard library, like any open source pr

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread Thomas Güttler
Am 18.04.2017 um 13:17 schrieb Peter Otten: Thomas Güttler wrote: I would like to have read-only class properties in Python. I found this http://stackoverflow.com/questions/128573/using-property-on-classmethods But there are a lot of discussions of things which I don't understand. I want to b

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-18 Thread Mats Wichmann
On 04/18/2017 04:00 AM, Thomas Güttler wrote: > I would like to have read-only class properties in Python. > > I found this > http://stackoverflow.com/questions/128573/using-property-on-classmethods > But there are a lot of discussions of things which I don't understand. > > I want to be a user o

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-18 Thread Alan Gauld via Tutor
On 18/04/17 11:00, Thomas Güttler wrote: > I would like to have read-only class properties in Python. Is there a specific reason why? Do you think for example that users of the class will deliberately try to modify the attribute? Normally in Python we leave all attributes public and unprotected (p

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-18 Thread Peter Otten
Thomas Güttler wrote: > I would like to have read-only class properties in Python. > > I found this > http://stackoverflow.com/questions/128573/using-property-on-classmethods > But there are a lot of discussions of things which I don't understand. > > I want to be a user of class properties, not

[Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-18 Thread Thomas Güttler
I would like to have read-only class properties in Python. I found this http://stackoverflow.com/questions/128573/using-property-on-classmethods But there are a lot of discussions of things which I don't understand. I want to be a user of class properties, not an implementer of the details. I