And: # return as a string def itob_string(integer, count = 8): return "".join(str((integer >> i) & 1) for i in range(count - 1, -1, -1))
# return as an iterator (i.e [0, 0, 0, 0, 1, 0, 1, 0]) def itob_list(integer, count = 8): return [(integer >> i) & 1 for i in range(count - 1, -1, -1)] # return as a generator def itob_generator(integer, count = 8): return ((integer >> i) & 1 for i in range(count - 1, -1, -1)) -- http://mail.python.org/mailman/listinfo/python-list