Intersection of multiple lists/list of lists

Thomas Weholt thomas at bibsyst.no
Tue Oct 5 04:46:24 EDT 1999


Hi,

Was just wondering if anybody cared to help me with this problem :

I got a program were the user will search a database based on keywords.
Example use :

app_name -s python rpm src
where -s is the option used for searching the database, the rest is
words to search for, app_name is eh ... well, the script.
The first thing that will be done is to fetch entries in the keywords
database, organized as dictionaries :

python = 432,5435,533,54343,5344 ...
rpm = 42432,43246,533,6753,234,64644,66545,6446 ...
src = 43535,543636,533,6564,6547443,535633,256474 ...

Something like this perhaps :

for word in sys.argv(1:):
	words_dict[word] = dyna_list # the result from the dictonary could be a
lists or a string, containing entries later converted to a list
	
But here I need to create a new list-object for each keyword. I don`t
know how many keywords the user has specified so this has to be dynamic.
How can I create list-objects like this on-the-fly? Can I use a list of
lists? It will probably not be integers used for entry-ids in the end,
more likely strings, or lists if this is possible.

What I need is a way of making an intersection of this lists, so that
only entries containing all keywords will be displayed. The final
product should be a list to iterate, fetching the valid entries in
another database.

I`m a newbie to python, so be gently. 

PS! How can I find info on what module returns what kind of info? I look
into the os-module for info on what the stat-method returns, but I
didn`t find the info anywhere. Then I looked at the stat-module, but
that didn`t clear up anything either. I want to know how I can turn
(432432,43242,4356,0,1,543643754,765474) stuff the stat-method returns
into more readable text.

Thomas Weholt




More information about the Python-list mailing list