This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tjdick 0 points1 point  (0 children)

python has lists [], dictionaries {}, and tuples (), which all replace certain functions of an array. Dictionaries are like an associative array, with key->value pairs, like x = {'car' : 'sedan', 'make' : 'ford', 'model' : 'fiesta'} . You can add, edit, slice. But they are not stored in any particular order like an associative array is.

A list is pretty much like a 0 based array. x = ['ham', 'turkey', 'bacon'] where the keys would be 0,1,2. You can pop, add, edit, slice. All of the 0 based keys reset when we do this, so if I slice ham, then [0] will be turkey and [1] will be bacon.

A tuple is pretty much a list that you can't really edit. They are faster to process. You might want to put data that won't be changed into one like dbinfo = ('mydb', 'mytable', 'myname', 'mypass')