List containing objects and subclassing...
aoeu at go.com
Mon Jun 17 07:06:57 EDT 2002
"Shagshag13" <shagshag13 at yahoo.fr> wrote in message news:<adlcer$6lqd$1 at ID-146704.news.dfncis.de>...
> I need an advice, i have a python list containing only object "node", and i'm wondering if this
> is best to hold it in a python list (as by now) or if i should write a "nodes" object subclassing from
> list and implementing some other methods i need to process on node object (contained by this list)
> and that i do now from "outside", or if i should write my own container implementing __getitem__
> (i also have done that in another version)...
> [hash_i] --> [node_j] -> [node_k]...
> Which way is better OO practice ? which is the efficient one ?
> What are the pros and cons (maybe best oo vs efficient ?) ?
You'd have problems if you subclass list with possibly adding non-node
data into it. Shouldn't you just subclass tuple to get around this?
More information about the Python-list