Feeds:
Posts
Comments

Posts Tagged ‘Tuple’

You start your day, happily working with dictionaries…Life is good. >>> mydict = {‘key-a’: ‘value-a’, ‘key-b’: ‘value-b’} >>> mydict['key-a'] ‘value-a’ All of a sudden, storm clouds appear. Your dictionary variable accidentally gets assigned a list, and life is no longer good! >>> mydict = {‘key-a’: ‘value-a’, ‘key-b’: ‘value-b’} >>> mydict['key-a'] ‘value-a’ >>> mydict = [] [...]

Read Full Post »

What is a tuple?

I get asked this from time to time, so for the fun of it, I’ll post this: Tuples are immutable lists in python (and other languages).  Very lightweight, unchangable arrays.  They are used for storing multiple values in one variable (usually a fixed number of values). x = (1, 2, 3, ‘abc’) x[0] -> 1 [...]

Read Full Post »