Convert string to hex « Python recipes « ActiveState Code
list comprehensions. Though your snippet is nice, you should really have a look at least comprehensions. With a few built-in methods you can reduce your 8 lines of code (which is pretty slow because of the "extra work" I guess) to one: toHex = lambda x:""...