-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreatingClassEmployee.py
47 lines (36 loc) · 1.26 KB
/
CreatingClassEmployee.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
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
class Employee:
"documentaion for Employee class"
empCount = 0
def __init__ (self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print("Total Number of employee: %d"%Employee.empCount)
def displayEmployee(self):
print("Employee Name: %s\nSalary: %d\n"%(self.name,self.salary))
def __del__(self):
class_name = self.__class__.__name__
print (class_name, "destroyed")
emp1=Employee("rohan",1000)
emp2=Employee("goli",1500)
emp1.name
emp2.salary
emp2.displayCount()
emp2.displayEmployee()
#hasattr(emp1, 'age') # Returns true if 'age' attribute exists
#getattr(emp1, 'name') # Returns value of 'age' attribute
#setattr(emp1, 'salary', 8) # Set attribute 'age' at 8
#delattr(empl, 'salary') # Delete attribute 'age'
#emp1.displayEmployee()
print ("Employee.__doc__:", Employee.__doc__)
print ("Employee.__name__:", Employee.__name__)
print ("Employee.__module__:", Employee.__module__)
print ("Employee.__bases__:", Employee.__bases__)
print ("Employee.__dict__:", Employee.__dict__)
class TCS(Employee):
"Documentation for TCS Employee"
empCount=0
def __init__(self):
print("Calling TCS Class")