[XML-SIG] Ugh! Why are DOM access methods spelled with a leading '_'?

Jim Fulton jim@digicool.com
Mon, 26 Jun 2000 10:09:57 -0400

Paul Prescod wrote:
> "Fred L. Drake, Jr." wrote:
> >
> > ...
> >
> >  > Is there are description somewhere of the Python DOM mapping,
> >  > other than the DOM sources?
> >
> >   The W3C documentation gives the IDL mapping, which requires the
> > Python specific mapping.
> Actually, the DOM can be mapped into a language in a manner that does
> not follow directly from the IDL and CORBA specs. That's why there is a
> formally defined java binding rather than just a reference to the IDL
> specs. Historically, though, 4DOM was really a CORBA tool so it really
> needed to follow the specs.

Whatever we do, there needs to be a document somewhere that
says what the Python DOM mapping is, even if it is not
much more than a reference to the DOM IDL and the Python

> I would vote for losing the leading underscore.

> > This says to me that the DOM API specifies use of methods
> > for interface attributes.
> I think it is safe to say that a binding should not require a particular
> underlying data structure but Python allows the use of a.b syntax even
> when the surface structure is wildly different than the underlying data
> structure. I'm preaching to the choir as you are the world leader in
> abuse of the dot notation. :)

Yup, however __getattr__ is a pain to utilize unless you have alot of 
infrustructure.  Zope has support for computed attributes, which makes 
this pretty sane, especially for read-only attributes.  I'm working on
a new version of StructuredText, StructuredText NG, 
which, among other things, creates objects with a DOM interface.
I want this to be independent of Zope, so I can't use any of the standard
Zope getattr tricks. 

In general, I think it would be cool of lots of
objects supported the DOM interface and I hate to make people 
jump over the getattr barrier to do that.  

Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for