This is the example of using properties given in the Python documentation:
Class C(object):
def __init__(self):
self._x = None
def getx(self):
return self._x
def setx(self, value):
self._x = value
def delx(self):
del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")
As far as I can tell, this behaves just like a regular property-less instance variable:
Class D(object):
def __init__(self):
self.x = None
Of course this doesn't have the ability to add additional logic to the getter or setter, but, since there is no difference in how other code interacts with C and D, you could always add a property later if you needed it without breaking any other code.
I know that this creates a problem if you use mutable types that are declared at the class level, i.e.:
class E(object):
x = [1,2,3]
Apart from that case, though, is it bad practice to leave out the properties until it they are needed or is it acceptable?
Thanks!