Best way to represent an outline?

VanL news at lindbergs.org
Thu May 9 10:02:45 EDT 2002


Hello,

I'm trying to figure out the best way to represent an 
outline, but I'm not sure what to use for each node:

A dict: This is probably the best fit, with the name serving 
as a key to another dict with different types of content. 
But the problem is that an outline is ordered, where dicts 
are inherently unordered.

A class:  This would probably work, but I don't want the 
types of items that I will include within each class 
instance to necessarily be pre-defined.  So it seems like it 
would be difficult to loop over the instance and discover 
everything in a particular node.  Plus, even if I used the 
__dict__, I still have the ordering problem described above.

A list:  This satisfies the ordering property needed for an 
outline, but I'm not sure where I would stick the variable 
content of each node.

Any suggestions?

TIA,

Van




More information about the Python-list mailing list