Last active
July 20, 2021 07:01
-
-
Save huytung228/be0d3c77df2deac66dc94e5ab63d735c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee: | |
def __init__(self, first, last): | |
self.first = first | |
self.last = last | |
@property | |
def email(self): | |
return '{}.{}@email.com'.format(self.first, self.last) | |
@property | |
def fullname(self): | |
return '{} {}'.format(self.first, self.last) | |
@fullname.setter | |
def fullname(self, name): | |
first, last = name.split(' ') | |
self.first = first | |
self.last = last | |
@fullname.deleter | |
def fullname(self): | |
print('Delete Name!') | |
self.first = None | |
self.last = None | |
emp_1 = Employee('John', 'Smith') | |
emp_1.fullname = "Corey Schafer" | |
print(emp_1.first) | |
print(emp_1.email) | |
print(emp_1.fullname) | |
del emp_1.fullname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment