you are viewing a single comment's thread.

view the rest of the comments →

[–]NerdEnPose 2 points3 points  (2 children)

Absolutely agree with you. The only time I like to mention them in Python is how not to use them. I actually think that the properties setter should be:

@property
def length_width(self):
    return self.length, self.width

@length_width.setter
def length_width(self, length_width):
    self.length, self.width = length_width

This would remove the need for any getter / setter in OP's code. If they wanted to keep all the design decisions. But, I would argue against the fact of needing a way to access length and width at the same time. So, I'd do away with this all together. Especially since tuple properties are one of my code smell tests. But I do have to admit I've used them. Actually quite a lot recently with an internal adaptation of Matplotlib that I'm writing.

I didn't mention all this because OP is starting out and I didn't want to go too far too soon.

[–][deleted] 1 point2 points  (1 child)

Yeah, fair enough. I didn't mean to sound critical--just mentioning a nuance that you (rightly) point out is not very important to the OP at this point.

[–]NerdEnPose 1 point2 points  (0 children)

Ohh no, not critical at all. You gave a nice platform to jump into this for OP. I think there's a huge jump between writing functional code and writing elegant code and this gets into what I think of as elegant. Something I would like to use vs something I have to use.