Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 16_class_and_objects.py #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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")