[XML-SIG] foo.bar vs. foo.get_bar()
Greg Stein
gstein@lyra.org
Fri, 5 Nov 1999 14:22:03 -0800 (PST)
On Fri, 5 Nov 1999 uche.ogbuji@fourthought.com wrote:
>...
> The real mess comes about if MyNode's programmer wants to use __[g/s]etattr__
> for whatever reason.
Presuming your DOM uses those already.
> So the list of knocks against "node.parent" is now:
>
> * Probably slower
> * Complex behavior masked in a supposedly simple attribute access
> * Possible confusion and complexity in sub-classing situations
IFF __getattr__ is used. If the attribute actually exists, then this is
the fastest approach possible. This is why qp_xml is so quick -- it has
all the attributes already assigned and clients just grab the values.
> So far, its main plusses are that it's clean, pythonic, and in close
> correspondence to the W3C API specifications.
Definitely.
> Note that I don't like the idea of the Python binding officially supporting
> two approaches, i.e. "node.parent" _and_ "node.get_parent()". I think it's
> great for implementations to provide alternatives, but the binding should
> require one unequivocally.
I'm in "violent agreement" here :-)
Cheers,
-g
--
Greg Stein, http://www.lyra.org/