The Python docs say all that needs to be said, as far as I can see.

setattr(object, name, value)

This is the counterpart of getattr(). The arguments are an object, a string and an arbitrary value. The string may name an existing attribute or a new attribute. The function assigns the value to the attribute, provided the object allows it. For example, setattr(x, 'foobar', 123) is equivalent to x.foobar = 123.

Answer from Chris Morgan on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_setattr.asp
Python setattr() Function
The setattr() function sets the value of the specified attribute of the specified object.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ built-in โ€บ setattr
Python setattr() | Programiz
August 21, 2024 - If the attribute is not found, setattr() creates a new attribute an assigns value to it.
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ python-setattr
Python's setattr function and __setattr__ method - Python Morsels
June 9, 2022 - Python's built-in setattr function can dynamically set attributes given an object, a string representing an attribute name, and a value to assign.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-setattr-method
Python setattr() method - GeeksforGeeks
July 11, 2025 - Python setattr() method is used to assign the object attribute its value. The setattr() can also be used to initialize a new object attribute.
๐ŸŒ
Real Python
realpython.com โ€บ ref โ€บ builtin-functions โ€บ setattr
setattr() | Pythonโ€™s Built-in Functions โ€“ Real Python
The built-in setattr() function allows you to set the value of an attribute of an object dynamically at runtime using the attributeโ€™s name as a string.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 17020115 โ€บ how-to-use-setattr-correctly-avoiding-infinite-recursion
python - How to use __setattr__ correctly, avoiding infinite recursion - Stack Overflow
I want to define a class containing read and write methods, which can be called as follows: instance.read instance.write instance.device.read instance.device.write To not use interlaced classes, m
๐ŸŒ
Python Tutorial
pythontutorial.net โ€บ home โ€บ python built-in functions โ€บ python setattr
Python setattr() - Set a Value to an Attribute of an Object
October 2, 2022 - The setattr() function sets a value to an attribute specified by the string name of an object.
Find elsewhere
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ __setattr__
Python's __setattr__ method - Python Morsels
June 4, 2024 - Python evaluates attribute assignments by calling an object's __setattr__ method.
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python โ€บ built-in functions โ€บ setattr()
Python | Built-in Functions | setattr() | Codecademy
June 13, 2023 - The setattr() function is a built-in Python function used to set the value of a named attribute of an object.
๐ŸŒ
Toppr
toppr.com โ€บ guides โ€บ python-guide โ€บ references โ€บ methods-and-functions โ€บ python-setattr
Python setattr() Function: What is setattr in Python used for?
November 10, 2021 - Setattr in python function is used to assign new value to attribute of an object. It sets new specified value argument to specified attribute name of function's defined object.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-setattr-method
Python setattr() method - GeeksforGeeks
June 19, 2023 - Python setattr() method is used to assign the object attribute its value. The setattr() can also be used to initialize a new object attribute.
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ python-setattr-function
Python setattr() Function - AskPython
December 30, 2019 - Python setattr() function is used to set the attribute of an object, given its name. While being a very simple function, it can prove to be very useful in the context of Object Oriented Programming in Python.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ built-in โ€บ setattr()
Python setattr() - Set Attribute Value | Vultr Docs
September 27, 2024 - The setattr() function in Python is a built-in utility that provides a dynamic way to manage object attributes. It is particularly useful when attribute names need to be determined at runtime, or when working with objects and their properties ...
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ python-how-to-set-and-delete-object-attributes-using-setattr-and-delattr-417952
How to set and delete object attributes using setattr() and delattr() | LabEx
Understanding how to effectively manage object attributes is a fundamental skill for any Python programmer. The setattr() function in Python is used to set the value of an object's attribute dynamically.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ python_setattr_function.htm
Python setattr() Function
The Python setattr() function allows us to set a new value to an attribute of the specified object. It is used for creating a new attribute and setting values to it. It is one of the built-in functions and does not require any module to use this.
๐ŸŒ
ZetCode
zetcode.com โ€บ python โ€บ setattr-builtin
Python setattr Function - Complete Guide
The setattr function assigns a value to an object's attribute. It takes three parameters: the object, attribute name (string), and value to assign. Key characteristics: works with any Python object, enables dynamic attribute assignment, and is equivalent to obj.attr = value but more flexible.
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-setattr-builtin-function
Python setattr() - Set attribute for an object
class Student: name = 'Name' age ... setattr(student1, 'country', 'Canada') print(student1) ... Python getattr() This built-in function gets the value of an attribute of an object....
๐ŸŒ
W3Schools
devcom.w3schools.com โ€บ python โ€บ ref_func_setattr.asp
Python setattr() Function
The setattr() function sets the value of the specified attribute of the specified object. ... Get certified by completing a course today! ... If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an ...