What is the etiquette in python for access "private" attributes of another instance of the same class?

45 Views Asked by At

I know that in python there are no formal ways to introduce private attributes of a class, and usually you just denote something private by prepending an underscore _.

I have a class that looks like below:

class my_class:
  def __init__(self):
    self._attr1 = # some initialization
  def method_that_merges_another_class_instance(self, other):
    # I want to access other's _attr1 attribute in here even though it's private. 

Is it acceptable to directly access _attr1 from other within method_that_merges_another_class_instance?

0

There are 0 best solutions below