[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-19 Thread dn via Python-ideas
On 19/10/2023 19.50, Dom Grigonis wrote: Thank you, Good information, thank you. Was not aware of __set_name__. IIRC that was one of the updates/improvements. Thanks to whomsoever...! The: instance.__dict__[self.name] = value may require a bit of thought before it feels comfortable,

[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-19 Thread Dom Grigonis
> On 19 Oct 2023, at 10:27, dn via Python-ideas wrote: > > On 19/10/2023 19.50, Dom Grigonis wrote: >> Thank you, >> Good information, thank you. Was not aware of __set_name__. > > IIRC that was one of the updates/improvements. Thanks to whomsoever...! > > The: > >instance.__dict__[s

[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-19 Thread Antoine Rozo
Hi, The __get__ method of descriptors can be called at the class level (that's how methods work) and in that case instance would be None, but owner will always reference the current class. __set__ can only be called for instances on that class (`Cls.attr = ...` would redefine the class-attribute

[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-19 Thread Dom Grigonis
Thank you, makes sense. This one has been bugging me every time I worked with descriptors. I even had __set__ method in my Descriptor Base for class attributes, but never needed it so didn’t realise. > On 19 Oct 2023, at 12:09, Antoine Rozo wrote: > > Hi, > > The __get__ method of descriptor

[Python-ideas] Re: Descriptor __get__ and __set__ argument discrepancy

2023-10-19 Thread dn via Python-ideas
On 19/10/2023 20.43, Dom Grigonis wrote: On 19 Oct 2023, at 10:27, dn via Python-ideas wrote: On 19/10/2023 19.50, Dom Grigonis wrote: Thank you, Good information, thank you. Was not aware of __set_name__. IIRC that was one of the updates/improvements. Thanks to whomsoever...! The: