raychenv / blog

my simple blog
1 stars 0 forks source link

getattr hasattr setattr #330

Open raychenv opened 1 year ago

raychenv commented 1 year ago

https://docs.python.org/3/library/functions.html?highlight=classmethod#setattr

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.