[Tutor] calling a variable name
Kent Johnson
kent37 at tds.net
Mon Oct 22 17:00:47 CEST 2007
Bryan Fodness wrote:
> Thank you. This works well. I am still trying to figure out the pros
> and cons of using an array, dictionary or list.
Array is specialized, you probably want list or dict.
Use list when you want a sequence of items indexed by sequential integers.
Lists
- preserve order
- are fast for indexed lookup
- are relatively slow (O(n)) for adding, deleting and searching (though
for small lists this should not be a consideration)
Use dict when you want to index by something other than sequential integers
Dicts
- do not preserve order
- are fast for adding, deleting and lookup
- can be used to replace a list search with a lookup
I'm sure there is more that I have missed. For your case I would start
with a list, I don't see anything requiring a dict.
Kent
More information about the Tutor
mailing list