-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.py
More file actions
42 lines (25 loc) · 770 Bytes
/
classes.py
File metadata and controls
42 lines (25 loc) · 770 Bytes
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
38
39
40
41
42
class Employee:
empCount= 0
def __init__(self, name, salary):
self.name= name
self.salary= salary
Employee.empCount+=1
def displayCount(self):
print("Total employees= "+str(Employee.empCount))
def displayEmployee(self):
print("Employee Name: "+ self.name)
print("Employee Name: "+ str( self.salary))
e1= Employee("Jonh McCain",2500)
e2= Employee("Sylvester",32500)
e2.jobTitle="Clown"
setattr(e1,"dynamicAttr","Setting attr dynamically on fly! so cooool!")
print(e2.jobTitle)
print(e1.dynamicAttr)
print(hasattr(e1,"dynamicAttr"))
print(hasattr(e2,"dynamicAttr"))
del e1.dynamicAttr
delattr(e2,"jobTitle")
getattr(e1,"salary",)
e2.displayCount()
e2.displayEmployee()
print( 0 == 0)