|
lut = {'color space': 'rgb',
'orange': [1.0, 0.4, 0.2],
'purple': [0.6, 0.0, 0.6]}
items = [('color space', 'rgb'),
('orange', [1.0, 0.4, 0.2]),
('purple', [0.6, 0.0, 0.6])]
lut = dict(items)
print lut['color space']
print lut['orange']
if not lut.has_key('blue'):
print 'no blue'
if 'blue' not in lut:
print 'no blue'
print lut.keys()
print lut.values()
print len(lut)
r,g,b = lut['orange']
print '%1.3f,%1.3f,%1.3f' % (r,g,b)
lut['purple'] = [1.0,0.2,0.8]
|
define a simple color lookup table
rgb
[1.0, 0.40000000000000002, 0.20000000000000001]
no blue
no blue
['orange', 'purple', 'color space']
[[1.0, 0.40000000000000002, 0.20000000000000001], [0.59999999999999998, 0.0, 0.59999999999999998], 'rgb']
3
get the rgb components
1.000, 0.400, 0.200
assign new values to "purple"
|