Lists and Sublists
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Tue Oct 23 18:21:16 EDT 2007
dineshv a écrit :
> We have a list of N (>2,000) keywords (of datatype string). Each of
> the N keywords has associated with it a list of names of varying
> numbers. For example, keyword(1) will have a list of L1 names
> associated with it, keyword(2) will have a list of L2 names associated
> with it and so on with L1 not equal to L2 etc. All keywords and names
> are immutable.
>
> Given a keyword(n) , we want to get hold of the associated list of Ln
> names.
>
> At anytime, we also want to add keywords to the list of N keywords,
> and to any of the associated Ln lists - both of which will grow to
> very large sizes.
>
> The data will be read into the Python data structure(s) from disk
> storage.
>
> I am struggling to work out what is the ideal Python data structure
> for the above. Any help would be greatly appreciated.
keywords = {}
keywords['python'] = ['fun', 'simple']
keywords['another_p_language'] = ['line noise', 'cryptic']
keywords['python'].append('readable')
HTH
More information about the Python-list
mailing list