On Sat, Feb 12, 2022 at 5:32 PM Steven D'Aprano <st...@pearwood.info> wrote:
> > I have to say I agree with Neil here. I was trying to think about what > > other reasons an attribute might be unsettable, and did not quickly come > up > > with that list. > > I'm curious what list you came up with if it excluded the three cases I > suggested (no __dict__, __slots__, property). What other cases are > there? > You're giving me far too much credit -- I hadn't thought about it that much but "no __dict__" was all I cam up with quickly -- and I had no idea what other possibilities there were. (Once I was reminded of__slots__) > > And after reading your list, I tried to imagine what I’d tell my > beginning > > students ! > > Tell them in what context? > > Have you already covered properties? If so, then it should be fairly > obvious what to tell them: > > "Class, what do you think will happen if you have a property with no > setter and you try to set its value?" > That's the easy part -- we cover that when we cover properties -- this whole thing is not an issue when you are working with your own code that you just added a property to. This issue Neil brought up is that if teh cause is p the chain of superclasses somewhere, you don't get much help from the error message. Telling newbies that that means that it's either a property with no setter, or am object without a __dict__, or one with __slots__ defined is not really very helpful. > But if the error message is indeed unique then yes: > > > > "can't set property 'f'" > > > > Would be far more clear message. > > As I said, I don't object to the change in wording if it is easy enough to > implement. > I think we're all on the same page here. -CHB -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/UJ4KICMH657QYMTOR6RCLDECF2JPIZ5D/ Code of Conduct: http://python.org/psf/codeofconduct/