Add object properties in retrospect using python -
i'm creating program reading in data different text files , saves information objects. have no problem creating object information of 1 text file.
imagine example if create class looks 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 create object half of attributes this:
stock = stock(company_name, 0, share_price, 0, 0, beta_value, 0, 0)
how later on add further information same object, if have many objects, example:
stock = stock(0, solidity, 0, p_e, p_s, 0, max_value, min_value)
you can assign values want this
stock.solidity = solidity stock.p_e = p_e stock.p_s = p_s stock.max_value = max_value stock.min_value = min_value
Comments
Post a Comment