list/tuple/dict question

bruce bedouglas at earthlink.net
Sun Aug 17 23:16:43 CEST 2008


hi guys/gals...

got a basic question that i can't get my hands around.

i'm trying to programatically create/use a list/tuple (or whatever the right
phrase in pyton is!!)

basically, something like:
 foo = []
 foo.append('cat')
 foo.append('dog')

 foo[1] = [] (and in this case, i really want to have a list called 'cat' to
be created!!)

when i've tried this, i don't get a list called 'cat', instead (as i
expected) the foo[1] is now a [] (list))

so foo is now
 ['cat', [] ]

ultimatelly , i want to be able to dynamically create a number of lists that
i name/create/manipulate on the fly, within the test app.

ie, be able to then create a list/array cat = ['a','b','c',....]

a dict doesn't seem to work, as it is essentially a series of key/values,
which isn't exactly what i want...

thoughts/comments/code samples would be reatly appreciated.

looking at various sites/samples cia google hasn't helped...

thanks





More information about the Python-list mailing list