How do you do data abstraction in Python?
Python does not have traditional access specifiers like private, protected, or public as seen in some other languages. Instead, it relies on naming conventions to indicate the intended access level. Attributes and methods with a single underscore prefix (e.g., _attribute
) are considered protected (internal use), and those with a double underscore prefix (e.g., __attribute
) are considered private (name mangling is applied).