Ir al contenido

Private underscore prefix (ARCH2009)

Esta página aún no está disponible en tu idioma.

Key python.naming.private-underscore-prefix · Severity info · Category naming

Private members meant for internal use should be marked with a single leading underscore per Python convention. Without that signal, outside code may rely on them and create brittle coupling.

class Cache:
def __init__(self):
self.store = {} # internal but unprefixed
def evict(self): # internal helper, unprefixed
self.store.clear()
class Cache:
def __init__(self):
self._store = {}
def _evict(self):
self._store.clear()

Add a single leading underscore to internal members and methods (e.g. store → _store).