Le 17/05/2017 à 13:08, Stephan Houben a écrit :
Now OPP is already hard to teach to my students, but if I have to add this to the mix, I will just have to tell them to copy / paste it blindly for a long time before I can get to the point they can understand what it does.
About the teachability, some remarks:
Comparing setting instance attributes to metaclasses is pushing it don't you think ?
The thing is, teaching OOP is challenging enough. You have __init__ and all it's quicks, and the @decorators for class methods, and self, and cls, and inheritances. And that's just the basics, not talking about multiple inheritance, properties, other dunder methods or compostion.
Having a cleaner, faster solution to declare a class would be awesome, both for dev and for teaching. That's why we all love attrs.
But we are talking here about a nice-to-have feature. Python works perfectly fine without it. But since we are at it, let's make something great.
My guess is that, without the decorator, the attributes don't do anything. They are just declarative hints for the decorator to do the magic.
But even then, it's already an additional burden to have to explain the difference between this magic and the regular class attribute. So if I have to do it, I wish I could do it without having to explain also 2 namespaced function calls, one taking itself the return value of a call as a parameter, which BTW is a factory taking a constructor as a callback.
Do not over estimate the skills of newcommers in programming. They have a lot of things to learn.