Double underscores -- ugly?

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Feb 20 04:11:49 EST 2008


Please preserve attribution lines on the quoted material, so we can
see who wrote what at each level.

benhoyt <benhoyt at gmail.com> writes:

> > > 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. It's too similar to "__init__", so they would
> use some other name.
> 
> In other words, defining _init to mean what __init__ now means
> probably wouldn't cause name conflicts.

But it would conflict with the existing conventions. '_init' as a name
indicates that it's *not* treated specially, because it's not named
with double-underscores. Since it *is* treated specially by Python, it
would be confusing not to follow the convention for naming such
attributes.

-- 
 \     "I know you believe you understood what you think I said, but I |
  `\         am not sure you realize that what you heard is not what I |
_o__)                                  meant."  -- Robert J. McCloskey |
Ben Finney



More information about the Python-list mailing list