# Single and Double Underscores in Python Names

DevFeed: [Single and Double Underscores in Python Names](<https://devfeed.tech/articles/single-and-double-underscores-in-python-names-100533.md>)

Original publisher: [Read original article](<https://realpython.com/python-double-underscore/>)

Author: Leodanis Pozo Ramos

Published: 2026-10-26T14:00:00Z

Content type: tutorial

Language: en

Sources: [Real Python](<https://devfeed.tech/sources/real-python.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Learning](<https://devfeed.tech/topics/learning.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>), [Inheritance](<https://devfeed.tech/topics/inheritance.md>), [identifier](<https://devfeed.tech/topics/identifier.md>)

Tags: [api-design](<https://devfeed.tech/tags/api-design.md>), [apis](<https://devfeed.tech/tags/apis.md>), [classes](<https://devfeed.tech/tags/classes.md>), [python](<https://devfeed.tech/tags/python.md>)

## AI overview

Python uses underscores to signal intent rather than enforce access restrictions: a single leading underscore marks names as non-public, while wildcard imports omit them unless they appear in `__all__`; direct imports can still access them. Double leading underscores trigger class-name mangling, which helps prevent accidental attribute or method collisions in subclasses, but does not make members inaccessible. A trailing underscore can avoid clashing with keywords or built-ins. Double underscores at both ends identify documented special methods and attributes used by Python, such as `__len__`. The article also covers underscore placeholders and named-tuple members, whose leading underscores help avoid field-name conflicts.

## Source excerpt

Learn Python naming conventions with single and double underscores to design APIs, create safe classes, and prevent name clashes.