[Tutor] data structures

Chris Fuller cfuller084 at thinkingplanet.net
Thu Dec 2 05:48:43 CET 2010

It sounds to me like all you need is for the values to be another dictionary, 
keyed on filename?  Don't use globals if you can help it.  You should be able 
to structure your program such that they aren't necessary.

Something like this?

features = {
    feature1': {'file1': 12, 'file2': 0, 'file3':6 }
    feature2': {'file1': 4, 'file2': 17, 'file3':0 }


On Wednesday 01 December 2010, Dana wrote:
> Hello,
> I'm using Python to extract words from plain text files.  I have a list
> of words.  Now I would like to convert that list to a dictionary of
> features where the key is the word and the value the number of
> occurrences in a group of files based on the filename (different files
> correspond to different categories).  What is the best way to represent
> this data?  When I finish I expect to have about 70 unique dictionaries
> with values I plan to use in frequency distributions, etc.  Should I use
> globally defined dictionaries?
> Dana
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list