A dict can be useful:

byte1, byte2 = 32, 1

conv1 = {(32, 32):0, (36,32):"natural", (32,1):5, (66,32):0.167}
print conv1[byte1, byte2]

If you use Psyco maybe something like this can be faster:

conv2 = dict((k1*256+k2,v) for (k1,k2),v in conv1.items())
print conv2[(byte1<<8) + byte2]

conv1/conv2 has to be defined just one time.

Bye,
bearophile

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to