copy

mail@pastecode.io avatar
unknown
python
2 years ago
421 B
2
Indexable
Never
class A:
    def __init__(self, name, age) -> None:
        self.name = name
        self.age = age


class B:
    def __init__(self, name=None, age=None, id=None) -> None:
        self.id = id
        self.name = name
        self.age = age


if __name__ == '__main__':
    a = A('Jisoo', '26')
    b = B(id=1)
    b.__dict__.update(a.__dict__)
    print('id:', b.id)
    print('name:', b.name)
    print('age:', b.age)