Python delattr() FunctionLast Updated : 17 Mar 2025 Python delattr() function is used to delete an attribute from a class. It takes two parameters first is an object of the class and second is an attribute which we want to delete. After deleting the attribute, it no longer available in the class and throws an error if try to call it using the class object. Python delattr() Function SyntaxIt has the following syntax: Parameters
ReturnIt returns a complex number. Different Examples for Python delattr() FunctionLet's see some examples of delattr() function to understand it's functionality. Python delattr() Function Example 1It is a simple example which contains a Student class, and by using delattr() function, we will delete it's email attribute. Output: AttributeError: 'Student' object has no attribute 'email' 101 Rohan [email protected] Python delattr() Function Example 2It throws an error if we delete an attribute which does not exist. Output: AttributeError: course Next TopicPython Functions |
We request you to subscribe our newsletter for upcoming updates.