Skip to content

Instantly share code, notes, and snippets.

@huytung228
Last active July 20, 2021 07:01
Show Gist options
  • Save huytung228/be0d3c77df2deac66dc94e5ab63d735c to your computer and use it in GitHub Desktop.
Save huytung228/be0d3c77df2deac66dc94e5ab63d735c to your computer and use it in GitHub Desktop.
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