[Python-ideas] Name mangling removal ?

Tarek Ziadé ziade.tarek at gmail.com
Sun Feb 1 22:40:39 CET 2009


On Sun, Feb 1, 2009 at 5:30 PM, Guido van Rossum <guido at python.org> wrote:
> This is the first time I've heard of this request.

The most recent one is here I think :
http://mail.python.org/pipermail/python-3000/2006-September/003857.html

> I'm against removing it. While the "privacy" it offers is marginal, it
> also offers protection against accidental clashes between attribute
> names. E.g. consider person A who writes a library containing a class
> A, and person B who writes an application with a class B that
> subclasses A. Let's say B needs to add new instance variables, and
> wants to be "future-proof" against newer versions of A that might add
> instance variables too. Using name-mangled variables gives B a
> "namespace" of his own (_B__*), so he doesn't have to worry about
> clashes between attribute names he chooses now and attribute names
> that A might choose in the future. Without name-mangling, B would have
> to worry that A could add private variables with clashing names as
> well -- in fact, the presence of any private variables in A would have
> to be documented in order to ensure that subclasses wouldn't
> accidentally clash with them, defeating the whole purpose of private.

Right, thanks for the explanation,

I found back a thread where it has been discussed already so I'll study it

http://mail.python.org/pipermail/python-dev/2005-December/058555.html


Regards
Tarek
-- 
Tarek Ziadé | Association AfPy | www.afpy.org
Blog FR | http://programmation-python.org
Blog EN | http://tarekziade.wordpress.com/



More information about the Python-ideas mailing list