I need to create a class that that stores tax data as default values, but that can be populated with actual data from tax returns. So for instance, let's say I have three categories: income, statutory adjustments, and tax computation, each which contains several attributes. Ideally, I would like to have three self arguments that I can pass around to parts of a tax calculator. But I would want to be able to pass around each attribute in the self string individually. Right now I have this:
class taxReturn:
def __init__(self):
self.income = [attribute1, attribute2, attribute3]
self.statut = [attribute4, attribute5, attribute6]
self.tax_comp = [attribute7, attribute8, attribute9]
Each attribute would have to be set to a default value that could be passed around, but then later filled in with actual data.
Any help would be appreciated. Thanks!
Why not just define this in the __init__
method?
class taxReturn:
def __init__(self, income = [attribute1, attribute2, attribute3],statut = [attribute4, attribute5, attribute6],tax_comp = [attribute7, attribute8, attribute9]):
self.income = income
self.statut = statut
self.tax_comp = tax_comp
# To create instance of taxReturn:
txR = taxReturn() # income, statut and tax_comp will take the default values defined bellow
//OR
txR = taxReturn(income = NewListOfAttribute1, statut=NewListOfAttribute2,tax_comp=NewListOfAttribute3) # income, statut and tax_comp will take the new attribute defined
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.