# Implicit initialisation of inherited attributes

**URL:** <https://discuss.python.org/t/implicit-initialisation-of-inherited-attributes/4849>\
**Category:** Ideas\
**Created:** [July 26, 2020, 8:12pm UTC](https://discuss.python.org/t/implicit-initialisation-of-inherited-attributes/4849 "2020-07-26T20:12:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![EpicWink](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/epicwink/32/17968_2.png) [@EpicWink](https://discuss.python.org/u/EpicWink)\
**Post date:** [July 27, 2020, 2:18am UTC](https://discuss.python.org/t/implicit-initialisation-of-inherited-attributes/4849/4 "2020-07-27T02:18:56Z")

</div>

I’ve implemented a metaclass that achieves your syntax:

```python
import inspect

class ImplicitParentInitMeta(type):
    def __call__ (cls, **kwargs):
        self = object. __new__ (cls)
        for cls_ in cls. __mro__ :
            if isinstance(cls_, ImplicitParentInitMeta):
                sig = inspect.signature(cls_. __init__ )
                kw = {n: kwargs[n] for n in sig.parameters if n in kwargs}
                cls_. __init__ (self, **kw)
        return self

class A(metaclass=ImplicitParentInitMeta):
    def __init__ (self, a):
        print("A", a)

class B(A, metaclass=ImplicitParentInitMeta):
    def __init__ (self, b):
        print("B", b)

...

```

---

_[View the full topic](https://discuss.python.org/t/implicit-initialisation-of-inherited-attributes/4849)._
