list/tuple/dict question

Fredrik Lundh fredrik at pythonware.com
Sun Aug 17 23:27:03 CEST 2008


bruce wrote:

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

so what do you think a variable namespace is?

as usual, Python works best if you use it to write Python program, and 
in Python, the right way to store a collection of name/value pairs is to 
use a dictionary:

  stuff = {}

  foo = []
  foo.append('cat')
  foo.append('dog')

  stuff[foo[1]] = []

</F>




More information about the Python-list mailing list