Double underscores -- ugly?

Bruno Desthuilliers bruno.42.desthuilliers at
Wed Feb 20 12:02:46 CET 2008

benhoyt a écrit :
>>> Then again, what's stopping us just using a single leading underscore?
>>> Nobody calls their own private methods _init or _add
>> You must be looking at different code from the rest of us. A single
>> leading underscore on the name *is* the convention for "this attribute
>> is not part of the external interface", which is about as "private" as
>> Python normally gets.
> Yeah, I understand that. I meant -- and I could be wrong -- that I
> haven't seen people creating a method called "init" with a single
> leading underscore.

Can you see me ?

> It's too similar to "__init__", so they would use
> some other name.

Nope. It's perfect for a template method that is supposed to be called 
from the parent's class __init__.

> In other words, defining _init to mean what __init__ now means
> probably wouldn't cause name conflicts.

It would.

What you obviously fail to understand is that the __magic_name__ 
convention is here to clearly separate language implementation space 
from user space. Your suggestion would break this.

More information about the Python-list mailing list