-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython | self.py
More file actions
43 lines (29 loc) · 1.16 KB
/
python | self.py
File metadata and controls
43 lines (29 loc) · 1.16 KB
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
####################################################### self ########################################################
# self
> self is a ddefault parameter in instance methods and constructor
> In a class 'self' represents 'current class object reference'
> we can rename the self word
##############################################################################
class Employee:
def __init__(self, idno, name, contact):
self.idno = idno
self.name = name
self.contact = contact
def show(self):
print("ID NO", self.idno)
print("Name", self.name)
print("Contact Number", self.contact)
eo = Employee(980, "official tech", 320)
eo.show()
################################################################################
class Employee:
def __init__(whatever, idno, name, contact):
whatever.idno = idno
whatever.name = name
whatever.contact = contact
def show(hereToo):
print("ID NO", hereToo.idno)
print("Name", hereToo.name)
print("Contact Number", hereToo.contact)
eo = Employee(980, "official tech", 320)
eo.show()