How to set a python property in __init__
class STransaction(object):
"""A statement transaction"""
def __init__(self, date):
self._date = None #1
self.date = date #2
If you want to set the proxy field self._date
without executing of your setter use the #1 line. If you would like to execute the setter at startup too use the #2. Both ways are correct, it's just a matter of what do you want to do.
I do not see any real problem with your code. In __init__
, the class is fully created and thus the properties accessible.