Python: Dataclass that inherits from base Dataclass, how do I upgrade a value from base to the new class?
问题 How can I upgrade values from a base dataclass to one that inherits from it? Example (Python 3.7.2) from dataclasses import dataclass @dataclass class Person: name: str smell: str = "good" @dataclass class Friend(Person): # ... more fields def say_hi(self): print(f'Hi {self.name}') friend = Friend(name='Alex') f1.say_hi() prints "Hi Alex" random_stranger = Person(name = 'Bob', smell='OK') return for random_stranger "Person(name='Bob', smell='OK')" How do I turn the random_stranger into a