> >>> import string > >>> string.zfill(hex(65)[2:],4) > '0041' > > The second parameter of string.zfill() specifies the number of digits > you want in the string. If there are fewer digits, the function pads > zeros to the left. The format operator (%) does all of that and is almost certainly faster. See the earlier messages. Alan G.