Answers for "python hide details"

1

python hide details

class MyClass:
    __hiddenVar = 12
    def add(self, increment):
       self.__hiddenVar += increment
       print (self.__hiddenVar)
myObject = MyClass()
myObject.add(3)
myObject.add (8)
print (myObject._MyClass__hiddenVar)
Posted by: Guest on November-06-2020

Python Answers by Framework

Browse Popular Code Answers by Language