python class private method code example
Example 1: python protected method
class example:
def __init__(self):
self._method1() #protected
self.__method3() #private
self.method3() #public
Example 2: private class method python
class Student:
def __init__(self):
pass
# The double underscore in the front makes it private
def __print_name(self):
return print("private")
# proof of use
def print_name(self):
return print("public")