delattr in Python

Python Methods and Functions

Removes the specified attribute from the object.

delattr (obj, name)

obj - object The object from which to remove the attribute.

name - str A string with the name of the attribute to be removed from the specified object. 


An object attribute (property, method, element) will be removed if the object allows / supports this action.

The method is often used in cases when the name of the attribute is not known in advance and is contained in a variable. 

Synonym: del directive.

getattr () is used to return an attribute .
Use setattr () to set an attribute.
Use hasattr () . 





Get Solution for free from DataCamp guru