Python delattr() Function

Example

Delete the "age" attribute of the "person" object:

class Person:
  name = "Bill"
  age = 63
  country = "USA"
delattr(Person, 'age')

Run Instance

Definition and Usage

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)