Skip to content
masterclass Buddy

Python · Function

setattr

setattr() assigns a value to an object's named attribute. It is useful when the attribute name is stored in a string or computed at runtime.

Last updated

Syntax

setattr(object, name, value, /)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • getattr()
  • delattr()
  • __getattribute__()
  • __slots__

Source: Built-in Functions. Checked 2026-11-03.