Privated and Protected in Python

#python #programming #class

  • There isn’t private and protected like Java in Python
  • Usually uses two underscores to simulate the behavior of private. For example self.__x
    • 1 can be used for protected or privated
  • Values can be modified even being when they are privated
Warning

Should not modify attribute outside its class

References

  • Ramalho, 2022, p381-383
#python #programming #class