Nice solution wanted: Hide internal interfaces

Peter Otten __peter__ at web.de
Mon Oct 29 13:17:56 EDT 2012


Johannes Bauer wrote:

> On 29.10.2012 17:52, Grant Edwards wrote:
> 
>> By "decleare them privide" do you mean using __ASDF__ name-munging?
>> 
>> It sounds to me like you're just making life hard on yourself.
> 
> Gaaaaaah, you are right. I just noticed that using the single underscore
> (as I do) does not restrict usage in any "non-natural" way. I was
> actually mixing this up in my head with the __xyz__ name-munging.

Name-munging occurs only if the method name starts but doesn't end with 
"__":

>>> class A(object): pass
... 
>>> class B(A):
...     __before = __between__ = __ = 42
... 
>>> set(dir(B)) - set(dir(A))
set(['__', '_B__before', '__between__'])





More information about the Python-list mailing list