Browse by Topic

Popular

Latest

Latest Python Posts

Illustration of a Python property decorator controlling access to an attribute, showing the getter and setter flow.
Python

Python Getter Setter: Using @property Correctly

Learn how Python implements getter and setter behavior with @property, when to use it, and how it differs from Java-style accessor methods.

Pythonpropertiesencapsulationobject-oriented programming
Illustration of Python encapsulation with a shield around class attributes and property accessor icons
Python

Python Encapsulation: Name Mangling and Properties

Understand Python encapsulation through name mangling and properties, with practical code examples, comparison, and tradeoffs for production class design.

encapsulationname manglingpropertiesobject-oriented programming
An illustration of a Python class with a private attribute being name-mangled to _ClassName__attribute.
Python

Python Private Variables: Name Mangling Explained

Learn how Python private variables work through name mangling, underscore conventions, and when each approach is useful for encapsulation.

pythonname manglingencapsulationobject-oriented programming
Illustration of a Python class with a private method marked by double underscore and a lock icon, representing encapsulation and name mangling.
Python

Python Private Methods: Naming Conventions and Name Mangling

Python private methods are a naming convention, not enforced privacy. See how single and double underscores, name mangling, and inheritance affect class design.

name manglingpython conventionsencapsulationpython classes
Diagram showing how Python rewrites a double underscore attribute name inside a class body.
Python

Python Double Underscore Name Mangling Explained

Learn how Python's double underscore name mangling rewrites attribute names inside classes, why the rule exists, and when to use it.

name manglingpython classesattribute privacyinheritance
Diagram showing Python name mangling transforming __attr to _ClassName__attr inside a class.
Python

Python Name Mangling: How Double Underscores Work

Learn how Python name mangling rewrites double-underscore attributes, why it prevents subclass collisions, and when a single underscore is the better choice.

name manglingPython classesattribute naminginheritance
Illustration of a Python class with a locked private attribute and a visible public interface.
Python

Python Private Attributes: Syntax and Limits

Understand how Python private attributes work through name mangling, why they aren't truly private, and when to use them for maintainable code.

name manglingencapsulationobject-oriented programmingdunder attributes
Illustration of a Python class with a protected attribute using the underscore convention
Python

Python Protected Attribute: Conventions and Pitfalls

Learn why Python's single underscore indicates a protected attribute by convention, how double underscore name mangling works, and when to use properties.

protected attributesname manglingaccess controlpython conventions
Illustration of a Python class with public attributes and property access, showing a lock icon for private attributes.
Python

Python Public Attribute: Definition and Access Control

Understand Python public attributes, naming conventions, and how to use properties to control attribute access in your classes.

python attributespropertiesencapsulationobject-oriented programming
Illustration of Python access levels showing public, protected, and private attribute layers with underscore conventions.
Python

Python Access Modifiers: How Encapsulation Really Works

python access modifiers: Learn how Python implements access control through underscore conventions, name mangling, and properties—and when each approach is appropriate.

pythonencapsulationname manglingproperties