Mere are my ramblings of a novice (bad) Hobbyst programmer. You mentioned that your having a hard time coming up with a solution to your complex problem. Complex means you are doing lots of different things to different things all over the place where timing is an issue.
First it seems you are trying to simplify your problem by creating a generic class you might call Element which is held in an ElementList class. Right? Or is it you would like you to create a new class for each unique element? If this is the case it would be because each unique element - behaves- differently. Is this the case? Or do all XML elements basically behave the same? If they behave the same you're confusing your design. A class represents a unique behavior. Remember instances can have unique attributes like "code" or "title". But I'm digressing. For example in your other discussion you posted at: https://groups.google.com/forum/#!topic/comp.lang.python/K9PinAbuCJk/discussion you say: So, an element like: <market code="WotF"> <title>Writers of the Future</title> </market> Or is the element structure?: <some_classname code="some_value"> <title>"some value"</title> </some_classname> Or is it like this? <some_classname some_tokenname="value"> <sub_element>value</subelement> </some_classname> Or like this? <some_classname some_tokenname="value"> <sub_element>value</subelement> <sub_element>value</subelement> ... </some_classname> Or this, typical XML? <some_classname some_tokenname="value"> <sub_element>value</subelement> <sub_element>value</subelement> ... <some_classname some_tokenname="value"> <sub_element>value</subelement> <sub_element>value</subelement> ... </some_classname> </some_classname> And is <sub_element> nested or only one "sub" deep? Ask yourself why do you need to have a different class for each unique element type? Or in other words, why do you need a new class for each XML tag pair? If your elements are nested to some unknown depth, perhaps broaden your idea of your ElementList into an ElementTree. Take a look at the section "Basic Usage" midway down at url: http://effbot.org/zone/element-index.htm Or change you Market Class stucture(in your other discussion) to make it more dimensional by adding a tag attribute which would mark it as if it were a certain "class". class ElementNode(objec): def__init__(self, parent, elem) self.parent = parent # another elementNode object or None self.elem = elem # entire text block or just do offsets (i.e. file line numbers) self.tag = self.get_tag(elem) # market tag==class self.token = self.get_token(self) # "code" or whatever if variable self.sub_elems= self.get_subs(elem) # recursive ElementNodes; return a list or dict self.root = self.get_root(parent) # optional but handy # I like to use the root as the XML source; sometimes an XML file self.next = None # because I love double link lists # probably useful for that ObjectListView wxPython widget If in your case each Element does behave differently (ie has unique methods) then perhaps you should be looking at some other solution. Perhaps class factories or meta classes. I can't help you there. -- http://mail.python.org/mailman/listinfo/python-list