Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Basics/Exercise/16_class_and_objects/16_class_and_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ def display(self):
print(f"ID: {self.id} \nName: {self.name}")


# Creating a emp instance of Employee class
# Creating an emp instance of the Employee class
emp = Employee(1, "coder")

emp.display()
# Deleting the property of object
del emp.id
# Deleting the object itself
try:
print(emp.id)
except NameError:
except AttributeError:
print("emp.id is not defined")

# Deleting the object itself
del emp
try:
emp.display() # it will gives error after deleting emp
except NameError:
print("emp is not defined")
print("emp is not defined")