[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-03 Thread Greg Ewing
On 3/07/20 6:33 pm, Serhiy Storchaka wrote: it is possible to implement pickling support for property objects which will fail with your example (and I think third-party libraries do it). The difference is that full qualified names of getter and setter differ from the full qualified name of the

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-03 Thread Greg Ewing
On 3/07/20 5:42 am, Matthew Einhorn wrote: Similarly, if you wanted to overwrite a property by using this property approach in the sub-class, but also call super for the parent's class property getter from within the get/set this wouldn't work!? Realised after sending that you were talking

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-03 Thread Greg Ewing
On 3/07/20 5:42 am, Matthew Einhorn wrote: I think what he may have meant is that if you tried accessing a double-underscore property of the outer class from the get/set methods, it won't properly de-mangle. Ah, I see what you mean. I don't think that's a fatal problem; double-underscore

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-03 Thread Serhiy Storchaka
02.07.20 13:26, Greg Ewing пише: On 2/07/20 8:04 pm, Serhiy Storchaka wrote: It has a problem with pickling (it is solvable). Can you elaborate? The end result is a property object just the same as you would get from using @property or calling property directly. I don't see how it can have

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Ricky Teachey
My personal feeling: I would love this idea (DRY gets me almost every time) if it weren't for that awful, terrible `class` keyword hanging out there. I wouldn't call using class this way "abuse", exactly, but it could be a potential use for an old idea raised more than once in the past: some kind

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Matthew Einhorn
On Thu, Jul 2, 2020, 6:30 AM Greg Ewing wrote: > On 2/07/20 8:04 pm, Serhiy Storchaka wrote: > > It has a problem with pickling (it is solvable). > > Can you elaborate? The end result is a property object just the > same as you would get from using @property or calling property > directly. I

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Chris Angelico
On Thu, Jul 2, 2020 at 8:38 PM Greg Ewing wrote: > > On 2/07/20 9:45 pm, Chris Angelico wrote: > > On Thu, Jul 2, 2020 at 7:41 PM Alex Hall wrote: > >> > >> On Thu, Jul 2, 2020 at 11:33 AM Chris Angelico wrote: > >>> > >>> What's the idea being discussed? AIUI there's no need or request to >

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Stestagg
Haha, I had no idea! That's great. fyi, judicious use of cython allowed our python team to build python components that far outperformed their java counterparts in some real-time middle-office financial processing jobs for a really large client. So thank you. I can see why using the standard

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Greg Ewing
On 2/07/20 10:49 pm, Stestagg wrote: Coincidentally, cython has a custom, deprecated syntax for properties that is actually pretty similar Not entirely a coincidence -- I invented that syntax for Pyrex, and Cython inherited it. I'm a little disappointed to hear it's been deprecated. :-( --

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Stestagg
Coincidentally, cython has a custom, deprecated syntax for properties that is actually pretty similar, and nice: cdef class Spam: property cheese: "A doc string can go here." def __get__(self): # This is called when the property is read. ...

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Greg Ewing
On 2/07/20 9:00 pm, Steven D'Aprano wrote: Perhaps Greg meant to say *up to* rather than "no less". What I said is true for sufficiently small values of 5. :-) You're right that it depends on how many operations you want. For reading and writing it's 3; if you want deleting as well it's 5.

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Greg Ewing
On 2/07/20 9:45 pm, Chris Angelico wrote: On Thu, Jul 2, 2020 at 7:41 PM Alex Hall wrote: On Thu, Jul 2, 2020 at 11:33 AM Chris Angelico wrote: What's the idea being discussed? AIUI there's no need or request to change the language/stdlib, but maybe I'm misreading. Ah, now I understand.

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Greg Ewing
On 2/07/20 8:04 pm, Serhiy Storchaka wrote: It has a problem with pickling (it is solvable). Can you elaborate? The end result is a property object just the same as you would get from using @property or calling property directly. I don't see how it can have any pickling problems beyond what

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Alex Hall
On Thu, Jul 2, 2020 at 11:33 AM Chris Angelico wrote: > On Thu, Jul 2, 2020 at 7:06 PM Alex Hall wrote: > > > > On Thu, Jul 2, 2020 at 9:34 AM Chris Angelico wrote: > >> > >> (Not sure why this is on python-ideas - wouldn't python-list be more > >> appropriate? Keeping it where it is for now

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Chris Angelico
On Thu, Jul 2, 2020 at 7:41 PM Alex Hall wrote: > > On Thu, Jul 2, 2020 at 11:33 AM Chris Angelico wrote: >> >> What's the idea being discussed? AIUI there's no need or request to >> change the language/stdlib, but maybe I'm misreading. > > Ah, now I understand. I did automatically assume that

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Chris Angelico
On Thu, Jul 2, 2020 at 7:06 PM Alex Hall wrote: > > On Thu, Jul 2, 2020 at 9:34 AM Chris Angelico wrote: >> >> (Not sure why this is on python-ideas - wouldn't python-list be more >> appropriate? Keeping it where it is for now though.) > > > As someone not familiar with the other lists...why?

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Chris Angelico
On Thu, Jul 2, 2020 at 7:04 PM Steven D'Aprano wrote: > That makes five by my count, however I hardly ever write a deleter so > three is more common, and only occassionally a setter so one is most > common :-) > Well, if you only want a getter, the most common way is fine. But if you then go to

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Alex Hall
On Thu, Jul 2, 2020 at 9:34 AM Chris Angelico wrote: > (Not sure why this is on python-ideas - wouldn't python-list be more > appropriate? Keeping it where it is for now though.) > As someone not familiar with the other lists...why? It's a proposal of an idea that could use some debate. Isn't

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Steven D'Aprano
On Thu, Jul 02, 2020 at 11:04:40AM +0300, Serhiy Storchaka wrote: > 02.07.20 10:12, Greg Ewing пише: > >The @property.getter and @property.setter decorators are > >clever, but they have the disadvantage that you end up > >writing the name of the property no less than 5 times, > >all of which have

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Serhiy Storchaka
02.07.20 10:12, Greg Ewing пише: The @property.getter and @property.setter decorators are clever, but they have the disadvantage that you end up writing the name of the property no less than 5 times, all of which have to match. 5 times? How is it? Thinking there must be a better way, I came

[Python-ideas] Re: An alternative way of defining properties (warning: contains creative abuse of the class statement)

2020-07-02 Thread Chris Angelico
(Not sure why this is on python-ideas - wouldn't python-list be more appropriate? Keeping it where it is for now though.) On Thu, Jul 2, 2020 at 5:14 PM Greg Ewing wrote: > > The @property.getter and @property.setter decorators are > clever, but they have the disadvantage that you end up >