Python Programming - Encapsulation - Discussion

Discussion Forum : Encapsulation - General Questions (Q.No. 58)
58.
In Python, how can encapsulation be enhanced to provide write access to a private variable 'value'?
class Example:
    def __init__(self):
        self._value = 0
Create a setter method for 'value'
Use a double underscore prefix for 'value'
Use a single underscore prefix for 'value'
Make 'value' a global variable
Answer: Option
Explanation:
To provide write access to a private variable, a setter method can be created to set the value.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.