#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    26
    Rep Power
    0

    Multi dimensional list help please


    i would like to build this:

    a IS LIKE b,c,d and e
    b IS LIKE r,f,s and l
    c IS LIKE q,w,u,i

    is this correct?
    Code:
    list = [[a, [b,c,d,e]],[b,[r,f,s,l]],[c,[q,w,u,i]]]
    or should i just make multiple flat lists
    Code:
    a = [b,c,d,e]  b = [r,f,s,l]
    my brain hurts when i think about this.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,966
    Rep Power
    481
    Programs transform input to output. What do you want to feed your program? What corresponding responses do you expect?
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    26
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Programs transform input to output. What do you want to feed your program? What corresponding responses do you expect?
    ahh yes.. i would like to feed the program a list of xml files from a tree and after i match those files to other file types in the tree with the same name but different extensions create some sort of connection between the two.

    Ie... file1.xml will pair with file1.txt, file1.dwg, file1.asp also
    file2.xml will match and pair with file2.txt, file2.dwg, file2.asp and
    so forth.
    I already have code to match everything up but i cant seem to figure out how to store it all conveniently.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,966
    Rep Power
    481
    Oh. I'd use a dictionary. The key is the file name, the value could be a set of file types or the whole file name if you don't care about the duplicated storage.


    {'file1':set(('xml', 'dwg', 'txt',)), 'file2':set(('xml', 'txt',))}
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo