Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1613,9 +1613,15 @@ method too, and it must do so carefully. The basic implementation of
self.__dict__[name] = value
...

Most :meth:`!__setattr__` implementations must modify
:attr:`self.__dict__ <object.__dict__>` to store
local state for self without causing an infinite recursion.
Many :meth:`!__setattr__` implementations call :meth:`object.__setattr__` to set
an attribute on self without causing infinite recursion::

class X:
def __setattr__(self, name, value):
# Custom logic here...
object.__setattr__(self, name, value)

Alternatively, it is possible to modify :attr:`self.__dict__ <object.__dict__>` directly.


How do I call a method defined in a base class from a derived class that extends it?
Expand Down
Loading