May-02-2023, 08:25 PM
(This post was last modified: May-02-2023, 08:26 PM by rjdegraff42.)
I think the question is what is clearer
I could make the case that it makes as much sense to standardize on
class A: @getter def foo(self): return 10 @setter def foo(self, value): print('Hello there!')
class A: @getter def foo(self): return 10 @foo.setter def foo(self, value): print('Hello there!')or
class A: def foo(self): return 10 foo = getter(foo) def foo(self, value): print('Hello there!') foo = setter(foo)I maintain that using @getter and @setter is clearer and less prone to errors since you only specify the method name one in the def statement. Especially since case 2 allows you to specify different names in the decorator and def lines. As a side note to consider, I have a very affectionate cat so typos are frequent.
I could make the case that it makes as much sense to standardize on
@foo.getter @foo.setteras it does on
@getter @setterExcept of course with the first format you still have the typo problem (which was the justification for the += operator).