Built-in Functions
delattr()
Delete a named attribute from an object.
delattr(object, name)
delattr() removes an attribute whose name is stored in a string. It does the same job as del object.name when the attribute name is known in advance.
Parameters
| Name | Description |
|---|---|
| object | The object or class that has the attribute. |
| name | The attribute name as a string. |
Returns
None; the attribute is removed.
Try it
Run it and change it
class User:
active = True
delattr(User, "active")
print(hasattr(User, "active"))