QuestionQ19

VerifiedObject-Oriented Programming

What behavior is expected from the following code?

Question Image

Explanation

A double-leading-underscore method name is name-mangled to _Class__foo within Class. Accessing it externally as o.__foo() does not use the mangled name, so it raises an AttributeError.

Community Discussion

No comments yet. Be the first to start the discussion!