Underscore data hiding (was python development practices?)

Tim Peters tim.one at home.com
Sun Nov 4 05:30:30 CET 2001


[Paul Rubin]
> I'd like to make the argument for removing the name mangling scheme
> from the language specification document.  It's fine to leave it in
> the implementation and it can be described in an implementation note.
> But if someone writes a new Python implementation they shouldn't be
> required to do it the same way, if they can find some alternative way
> to resolve collisions.  "Portable" (across Python implementations)
> applications shouldn't depend on name mangling working the way it does.

Paul, I didn't see "an argument" here, apart from repetition of "it
shouldn't".  Guido intended that it should, and that's why the specifics of
the name-mangling scheme are indeed documented in the Language Reference
manual.  It's intended that this code:

>>> class C:
...     __private = 1
...
>>> C._C__private
1
>>>

print "1" across all implementations; no scheme in which it doesn't will
make headway.

the-backward-compatibility-camp-has-no-worries-on-this-one-ly y'rs  - tim





More information about the Python-list mailing list