[XML-SIG] Trying to get Metaparser code segment working
Lars Marius Garshol
13 Mar 2000 08:09:26 +0100
* Yusuf Goolamabbas
| My apologies if this question is not relevant to this SIG.
No problem. :-)
| def startElement(self, name, attribs):
| exec('start_' + name + '(' + "self" + ',' + "attribs" + ')')
You probably mean
exec('self.start_' + name + '(' + "attribs" + ')')
but I'm not sure if that will work either, since attribs probably
won't be repr-ed and reparsed correctly. You could put it in as a
literal, but then I think you'd get scoping problems.
My suggestion is that you do as xmlllib:
method = getattr('self.start_' + name)