I am writing a banking application in Python
, and reading some source code from here Banking Application. The balance
class is defined below:
class Balance(object):
""" the balance class includes the balance operations """
def __init__(self):
""" instantiate the class """
self.total = 0
def add(self, value):
""" add value to the total
Args:
value (int): numeric value
"""
value = int(value)
self.total += value
def subtract(self, value):
""" subtract value from the total
Args:
value (int): numeric value
"""
value = int(value)
self.total -= value
My Question
Since balance details should not be accessed outside of a class, we should be defining the attribute self.total
as self.__total
since we should make it a private
rather public
variable? Is my line of thinking correct here?