-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInnerClass.py
More file actions
39 lines (30 loc) · 988 Bytes
/
Copy pathInnerClass.py
File metadata and controls
39 lines (30 loc) · 988 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
class student:
schoolname = "JPIS"
def __init__(self,name,percentage):
self.name = name
self.percentage = percentage
#object of inner class in constructor of outer class
self.personal = self.personaldetails(12,"Indian")
def show(self):
print(self.name , " ", self.percentage, end=" ")
#method to access class variable - key word is cls
@classmethod
def schoolInfo(cls):
return cls.schoolname
#static method
@staticmethod
def info():
return("This is a static method")
class personaldetails:
def __init__(self,age,citizenship):
self.age = age
self.citizenship = citizenship
def show(self):
print(self.age, " ", self.citizenship)
aryaa = student("Aryaa",97)
aryaa.show()
aryaa.personal.show()
personaldata = aryaa.personal
personaldata.show()
#print(student.info())
#print(student.schoolInfo())