[xml-bindings]More suggestions



Hi all,

I noticed that there are some things that appear similar to Python's
built-in types, but have a different interface. If their interfaces were
rearranged to be the same as the Python types then you could use the
built-in ways of handling them.

Node lists look a bit like Python lists, for example. Walking a linked
list is natural in C, but not in Python, and if stuff like node.children
had a Python list interface, then you could do things like:

 content = reduce(lambda x,y: x+y,
                  map(lambda n: "%s: %s\n" % (n.name, n.content), 
                      node.children))

which is far nicer than:

  content = ""
  n = node.children
  while 1:
    content = content + "%s: %s\n" % (n.name, n.content)
    if not n.next:
      break
    n = n.next

Also, Node properties look a bit like Python dictionaries.  Instead of
hasProp/newProp/prop it would be nicer if you could access it like a
dictionary, so you could say 'for prop in node.prop.keys()', 'if
node.prop.has_key("foo")' and 'uri = node.prop["href"]'. Not as valuable 
as the lists thing, but probably worthwhile.

Cheers,
Gary

[ gary inauspicious org ][ GnuPG 85A8F78B ][ http://inauspicious.org/ ]




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]