Skip to content

Commit 309fa59

Browse files
authored
Update oop.py
1 parent d2a371b commit 309fa59

File tree

1 file changed

+15
-0
lines changed
  • Object-Oriented/6-property-decorator

1 file changed

+15
-0
lines changed

Object-Oriented/6-property-decorator/oop.py

+15
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,25 @@ def email(self):
1212
@property
1313
def fullname(self):
1414
return '{} {}'.format(self.first, self.last)
15+
16+
@fullname.setter
17+
def fullname(self, name):
18+
first, last = name.split(' ')
19+
self.first = first
20+
self.last = last
21+
22+
@fullname.deleter
23+
def fullname(self):
24+
print('Delete Name!')
25+
self.first = None
26+
self.last = None
1527

1628

1729
emp_1 = Employee('John', 'Smith')
30+
emp_1.fullname = "Corey Schafer"
1831

1932
print(emp_1.first)
2033
print(emp_1.email)
2134
print(emp_1.fullname)
35+
36+
del emp_1.fullname

0 commit comments

Comments
 (0)