In a Python codebase, you see that a child class is trying to modify an attribute with two leading underscores from a parent class but encounters an error. What's the likely cause?

  • Python does not allow modifying attributes from child classes.
  • The attribute is marked as a protected attribute and can only be accessed within the parent class.
  • The attribute with double underscores is treated as a name mangling name, and it's not directly accessible from child classes.
  • The child class does not have proper inheritance from the parent class.
In Python, an attribute with double underscores (e.g., __attribute) is treated as a name-mangling name. It's not directly accessible from child classes to prevent accidental overwriting.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *