Python has no automatic access specifier protection like public
or private
. But you can always implement the logic yourself using a method. Do something like:
def incrementA(self, node):
if node.name == "Node A": self.valueOfA += 1
else: raise ValueError("node is not authorized to increment A")
Also, Python has no ++
operator. You need to use +=
to increment.