Add object properties in retrospect using python

Viewed 41

I'm creating a program that is reading in data from different text files and saves the information to objects. I have no problem creating an object from the information of one text file.

Imagine for example if I create a class that looks like the following:

class Stock:
    def __init__(self, company_name, solidity, share_price, p_e, p_s, beta_value, max_value, min_value):
        self.company_name = company_name
        self.solidity = solidity
        self.share_price = share_price
        self.p_e = p_e
        self.p_s = p_s
        self.beta_value = beta_value
        self.max_value = max_value
        self.min_value = min_value

And I create an object with only half of the attributes like this:

stock = Stock(company_name, 0, share_price, 0, 0, beta_value, 0, 0)

How do I later on add further information to the same object, even if I have many objects, for example:

stock = Stock(0, solidity, 0, p_e, p_s, 0, max_value, min_value)
2 Answers
Related