Origin of double underscore convention?

Steve Holden sholden at bellatlantic.net
Thu Jan 6 16:38:09 EST 2000


Probably just to avoid naming conflicts: since Python binds names
at run-time it looks them up in dictionaries.  If common methods
had names like "init" or "repr" the chances of conflict would be
much higher.

Of course with "mix-in" classes and/or multiple inheritance those
conflicts could more easily occur.  This was why "name mangling"
was introduced: again, to lower to odds of naming conflicts.

regards
 Steve

Jason Stokes wrote:
> 
> I'm relatively new to Python.  This is possibly a dumb question, but
> I'm wondering about the double underscore convention to mark an inbuilt
> or internal method.  I find it pretty ugly and I'm wondering if it was
> chosen for any historical reason, eg analogy to another language.  I
> know C programmers sometimes use the underscore convention.
> 
> --
> Jason Stokes: jstok at bluedog.apana.org.au



More information about the Python-list mailing list