@dataclass
class Stock:
symbol: str
price: float = get_price(symbol)
Can a dataclass attribute access to the other one? In the above example, one can create a Stock by providing a symbol and the price. If price is not provided, it defaults to a price which we get from some function get_price. Is there a way to reference symbol?
This example generates error NameError: name 'symbol' is not defined.