Function Details: delattr

Description


Deletes the named attribute from the given object.


Extended Description


The delattr() function deletes the named attribute from the given object. It is equivalent to 'del object.name'. This function is particularly useful when you need to remove an attribute dynamically, or when the attribute name is determined at runtime.


Exceptions


  • AttributeError: If the attribute doesn't exist
  • TypeError: If the object does not support attribute deletion

Read More about delattr from Python Documentation

Function Signature


delattr(object: Any, name: str) -> None

Module: builtins

Parameters


object: The object from which to delete the attribute. name: A string containing the name of the attribute to be deleted.


Parameter List


  • object: Any
  • name: str

Return


This function doesn't return a value; it modifies the object in-place.


Return Type


None

Output

Explanation

This example demonstrates how to use delattr() to remove an attribute from an object.