logoalt Hacker News

zahlman04/23/20250 repliesview on HN

>In other words, if it is supposed to be accessed directly by arbitrary external code

There is no such thing as "supposed to be" in this context. It can be accessed, because Python fundamentally doesn't protect against such accesses anywhere. There is no wrapper because there is no ordinary purpose for the access.

>If any property can have that syntax, then the syntax loses its meaning?

There is no special syntax here, so there is nothing that can lose meaning. Leading underscores are a convention. The parser doesn't care, and the compiler only makes minor adjustments (name mangling) in very limited circumstances (to avoid mistakes with subclasses).