I'm trying to put 2 constructor class in 1 constructor class with this code but:
class Buy:
def __init__(self, buy_value: float, buy_currency: str) -> None:
self.buy_value = buy_value
self.buy_currency = buy_currency
class Sell:
def __init__(self, sell_value: float, sell_currency: str) -> None:
self.sell_value = sell_value
self.sell_currency = sell_currency
class isCash(Buy,Sell):
def __init__(self, buy_value, buy_currency,sell_value, sell_currency) -> None:
super().__init__(buy_value, buy_currency)
super().__init__(sell_value,sell_currency)
obj1 = isCash(Buy(1,"mnt"),Sell(2,"mnt"))
print(obj1.__dict__)
Result
{'buy_value': 2, 'buy_currency': 'mnt'}
as you can see sell DICT is gone. Is there anyway that i can achieve this.
{
"buy": {
"buy_value": 1,
"buy_currency": "MNT"
},
"sell": {
"sell_value": 1,
"sell_currency": "MNT"
},
}
TypeError. - Klaus D.obj1 = isCash(Buy(1,"mnt"),Sell(2,"mnt"))wouldn't beobj1 = isCash(**Buy(1,"mnt").__dict__, **Sell(2 ,"mnt").__dict__)- Augusto Vasques