How to use private variable in python class in Tamil | Encapsulation in python #python
In Python, the use of a single underscore (_) and double underscores (__) before attribute names serves as a convention rather than a strict language feature. However, they do have different implications in terms of visibility and name mangling:
Single Underscore Prefix (_age):
This is a convention indicating that the attribute is intended to be "protected" or "private" (though not enforced by the language).
It suggests that the attribute should not be accessed directly from outside the class, but there are no technical restrictions preventing such access.
Double Underscore Prefix (__age):
This triggers name mangling in Python.
Name mangling is a technique to make an attribute "private" to its class.
When you define an attribute with double underscores (__), Python internally changes its name to include the class name as a prefix, making it more difficult to access from outside the class.
However, it's still possible to access these "private" attributes by using the mangled name (_ClassName__attributeName), though this is discouraged because it breaks encapsulation.
Auf dieser Seite können Sie das Online-Video How to use private variable in python class in Tamil | Encapsulation in python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer pycodedigi 15 Mai 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 217 Mal angesehen und es wurde von 7 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!