list to dict

Bart Nessux bart_nessux at hotmail.com
Wed Jun 16 19:16:32 CEST 2004


Larry Bates wrote:
> If the keys are just indexes that you would
> use in the dictionary, you don't need a
> dictionary at all.  Just index into the list.
> 
> list[0]->'book1'
> list[1]->'book2'
> list[2]->'book3'
> 
> You will need to deal with the indexes beginning
> at zero (not 1) or put None in list[0] an then
> don't reference it.
> 
> HTH,
> Larry Bates
> Syscon, Inc.

Thank you Larry, this is fascinating. From your  post, I now understand 
that a dictionary is much like a database.

For my purpose, I like the idea of an indexed list (this too reminds me 
of a database somewhat). Thank you for helping me to understand this. I 
can see other objects such as a phone book... I think a dictionary would 
be more appropriate for that as it's not really just an indexed list, 
but more of a database that associates a number (that has meaning and 
purpose) to a name.

Bart



More information about the Python-list mailing list