python private 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 variables python

# Python does not have any private variables like C++ or Java does.
# You could access any member variable at any time if wanted, too.
# However, you don't need private variables in Python,
# because in Python it is not bad to expose your classes member variables.