-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathproperty-3.py
37 lines (29 loc) · 878 Bytes
/
property-3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (C) Deepali Srivastava - All Rights Reserved
# This code is part of Python course available on CourseGalaxy.com
class Employee:
def __init__(self, name, password, salary):
self._name = name
self._password = password
self._salary = salary
@property
def name(self):
return self._name
@property
def password(self):
raise AttributeError('password not readable')
@password.setter
def password(self, new_password):
self._password = new_password
@property
def salary(self):
return self._salary
@salary.setter
def salary(self, new_salary):
self._password = new_salary
e = Employee('Jill', 'feb31', 5000)
print(e.name)
#e.name = 'dd'
#print(e.password)
e.password = 'feb29'
print(e.salary)
e.salary = 6000