0

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!

Alex Durante
  • 71
  • 2
  • 7

1 Answers1

0

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
farhawa
  • 10,120
  • 16
  • 49
  • 91
  • Great, that seems to be what I want to do. Sorry, I am fairly new to Python. So just to be clear, using this code, I will be able to pass around say just attribute 1 from income? – Alex Durante Oct 02 '15 at 14:05
  • @AlexDurante Sorry I did not understand whayt you want to say, can you explain that little more? – farhawa Oct 02 '15 at 14:20
  • Yes, sorry. So let's say the income string contains those three attributes. Suppose I on'y want to pass one of those attributes. Will I be able to do that using this code? – Alex Durante Oct 02 '15 at 14:38
  • Also, the attributes would be populated with imported data. So somehow those attributes would have to take on the values from the imported data. – Alex Durante Oct 02 '15 at 14:56
  • @AlexDurante, income is a list here, it's not a string. And what do you mean by "pass one of those attributes"? pass them where? – farhawa Oct 02 '15 at 15:15
  • Sorry, I meant list. So for instance, lets say as part of this tax calculator, I want to subtract say attribute4 from attribute1. I would want to only be able to pass those attributes to the next part of a tax calculator. Ideally, I would like to be able to pass these tax returns to a different class where I could calculate, say, taxable income. – Alex Durante Oct 02 '15 at 15:18