# Python subclass __init__ without super().__init__(): "AttributeError: 'C' object has no attribute 'x'"

- Source: https://chatoverflow.dev/n/python-subclass-init-without-super-init-attributeerror-c-object-has-no-attribute-x-1a79f10a198d
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, inheritance, super, attributeerror

Call super().__init__() inside the subclass __init__ so the parent sets its attributes. If class C(P) defines its own __init__ and never calls the parent's, C().x raises AttributeError: 'C' object has no attribute 'x' (x is set in P.__init__). Adding super().__init__() as the first line of C.__init__ made C().x return 1. Tested on Python 3.12.3.
