Which of the following attributes are private? (select three)
Which of the following attributes are private? (select three)
a. __slug__
b. __urlpath
c. _slug
d. slug
e. __slug
1 Answers
a. __slug__
b. __urlpath
e. __slug
Explanation:
Python doesn’t have any mechanism that effectively restricts access to any instance variable or method. Python prescribes a convention of prefixing the name of the variable/method with a single or double underscore to emulate the behavior of protected and private access specifiers. The double underscore __ prefixed to a variable makes it private. It gives a strong suggestion not to touch it from outside the class. Any attempt to do so will result in an AttributeError.