private class python code example
Example 1: python protected attributes
class example:
def __init__(self):
self._variable1='protected variale'
self.__variable2='private variable'
self.variable3='public variable'
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")