[XML-SIG] Reconsidering the DOM API

Walter Doerwald walter@livinglogic.de
Wed, 28 Jun 2000 16:32:16 +0200

At 15:22 28.06.00, Benjamin Saller wrote:

>Today, Walter Doerwald wrote:
>     Why not put children and attribute access into __getitem__
>              c =3D b[0][1][0]["abc"]
>Try to maintain that a month after you wrote it ;>

I don't see a problem here. When you want something that is short,
because you use it *all* *the* *time*, then you won't forget how it
works. What's the difference between remembering that [index] gives
you the index'th child and remembering that _get_childNodes(index)
does it?

And the implementation is straightforward:

         def __getitem__(self,index):
                 if type(index) =3D=3D types.IntType:
                         return self._get_childNodes(index)
                 elif type(index) =3D=3D types.StringType:
                         return self._get_attribute(index)
                         raise ValueError("wrong type for index")

(or whatever the DOM API will be)

         Walter D=F6rwald
Walter D=F6rwald =B7 LivingLogic AG =B7 Bayreuth, Germany =B7 www.livinglogi=