[XML-SIG] Ugh! Why are DOM access methods spelled with a leading
Mon, 26 Jun 2000 11:21:10 -0600
> Uche Ogbuji writes:
> > I should note that I quite hope that leading-underscore-means-private
> > is indeed not normative, and never will be so. The leading underscore
> > is the most readable way to escape symbol names that would clash with
> > an applicable naming convention.
> The use of a single "_" at the front of a name in Python has always
> (at least since about Python 1.2) been used to filter out names that
> should not be used outside a module. It is more than an idiom. The
> concept is enforced in statements of the form "from foo import *". It
> isn't absolutely enforced. You can still say "from foo import _thing".
Everything I hear is that it's a weak restriction. Maybe that doesn't matter.
> Arguing that other languages use "_" to eliminate name conflicts is a
> red-herring when talking about Python. Python namespaces make this
> unnecessary. It is annoying to some Python users to see an idiom from
> another language carried over to Python. In this case the carryover
> directly conflicts with a Python language feature.
All true, but we all use other languages to buttress our arguments when it
suits us, and protest against bleeding in idioms from other languages when it
doesn't. All's fair in flame and dialectic, no?
> > It's far from a conclusive argument
> > (though Jim Fulton tried to make a similar argument to excoriate the
> > Python/CORBA binding), but most languages, such as C++ allow exactly
> > this approach as put to good use by the C++/CORBA binding.
> > The leading-underscore-is-private idea has the annoying effect that if
> > I want to call a variable "class", I must instead use the silly
> > "klass", rather than "_class", which is far more readable and
> > self-explanatory. And if I want to call variables "def", "type" and
> > "else", what then? "deph", "tipe" and "els"? (I suppose one could
> > use trailing underscore).
> Why not use append a "_" to the name to distinguish it from a keyword.
> The name "class_" would be as readable and it wouldn't conflict
> with the longstanding Python rule for leading "_" characters.
That was what I said in my last parenthesis. It's a bit less natural to me,
but that's just viscera and there's no need for you to pay attention to it.
> > Most likely, Guido is already in his time machine writing "Thou shalt
> > not use leading underscore except for private variables" on a stone
> > tablet somewhere in the past to end the whole argument. But people
> > have been saying nasty things about the Python/CORBA binding which
> > wouldn't be as nasty as the things I'd say about such a restriction in
> > Python.
> The special meaning of _* is defined here:
> The rule is also discussed in section 6.1 of the Tutorial.
Still only a weak restriction, but in the interests of moving on to productive
work, I think it's time for me to concede this particular argument.
So what do we do about the underscores in the DOM binding?
Uche Ogbuji Principal Consultant
firstname.lastname@example.org +01 303 583 9900 x 101
Fourthought, Inc. http://Fourthought.com
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python