Skip to content
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

NameDescription
objectThe object or class that has the attribute.
nameThe 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"))

Related entries