Public, protected & private
# public-
# protected-
# private-
class myclass:
class_teacher = "sajita" # public
_protected = "chocolate" # protected
__private = "gf" # private
def __init__(self, aname, aaim):
self.name = aname
self.aim = aaim
student1 = myclass("harish", "software developer")
print(student1._protected)
print(student1._myclass__private) # the process of calling private value is called name mangling
Comments
Post a Comment