Python delattr() Function
Instance
Delete the "age" attribute of the "person" object:
class Person: name = "Bill" age = 63 country = "USA" delattr(Person, 'age')
Definition and Usage
The delattr() function will remove the specified attribute from the specified object.
Syntax
delattr(object, attribute)
Parameter Value
Parameter | Description |
---|---|
object | Required. Object. |
attribute | Required. The name of the attribute you want to delete. |
Related Pages
Reference Manual:getattr() Function(Get Attribute Value)
Reference Manual:hasattr() Function(Check If Attribute Exists)
Reference Manual:setattr() Function(Set Attribute Value)