Let’s say I have the following code:
class MyClass(object):
def __init__(self, param):
self.param = param
@property
def super_param(self):
return Param(self, self.param)
class Param(object):
def __init__(self, parent, param):
self.param = param
self.parent = parent
@property
def get_parent(self):
return self.parent
My question is, is it considered bad practice to use the @property decorator in this way? Are there any pros or cons?
Why not just
I don’t think there’s anything particularly wrong with returning a class from a property; a better question is, what are you trying to accomplish by doing so?
Edit: if you don’t want it changed, make it a private property: