[Tutor] Mapping elements in various lists - walking over lists andtheir elements

Alan Gauld alan.gauld at freenet.co.uk
Wed Apr 5 20:48:27 CEST 2006


> One of the proble is that, Contig27915_RC is seen
> associated with many XM entries in nbat.  However,
> with the above script I could replace only once in
> xta. I could not print Contig27915_RC with many XM_
> guys in nbat. How can this be done.
> 
> Finally, this whole process seems to be more
> cumbersome to me. Could any one tip me with a new way
> of dealing this 3 way mapping.

A common generic way to deal with this is to construct an 
intermediate data model such as a dictionary that contains 
the key element and a list of the keyed items in the file. 
The list could be the items themselves ort a tuple containing 
such info as their index (or seek position). Then you can iterate 
over the data making multiple changes as defined in the 
data structure.

This is somewhat similar to a thread last month, take a look 
in the archives for more ideas.

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list