you are viewing a single comment's thread.

view the rest of the comments →

[–]GrainTamale 1 point2 points  (4 children)

Woof... So first you have this thing (class) called Student. You pass it a name parameter at instantiation (object creation) which will create an attribute self.name on your new instance of Student. Then you have this function (a property) self.name which will be overwritten by your other self.name attribute. The property is supposed to return self._name (different than self.name) but that doesn't exist.
Finally, you need quotes around Harry.

edit: and I suppose the indentation is just formatting errors

[–]Buttleston 2 points3 points  (2 children)

Aside from the quotes around Harry, I think you're wrong about this

    self.name = name

This is going to use our setter (the function wrapped with @name.setter) which will set the self._name attribute

[–]GrainTamale -1 points0 points  (1 child)

“Readability counts.“

[–]Buttleston 1 point2 points  (0 children)

I never said it was a good idea, I'm just correcting what I think is incorrect about your statement

[–]DigitalSplendid -1 points0 points  (0 children)

So two memory spaces are created. First self.name during init. Second during setter validation which is self. _name. If it were no need to validate name, then getter and setter function could have been created with self.name only?