sentence = 'I do not like Green Eggs and Ham!'

"From http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/219300"
def tobin(x, count=8):
        return "".join(map(lambda y:str((x>>y)&1), range(count-1, -1, -1)))

s_bin = map(lambda ch: tobin(ord(ch)), sentence)
s_hex = map(lambda ch: hex(ord(ch))[2:].upper(), sentence)
s_chr = map(None, sentence)

bitblock = map(lambda cs: ''.join(cs), zip(*s_bin))

hexblock = map(lambda cs: ''.join(cs), zip(*s_hex))

print bitblock

print hexblock

"""

   0 0 00 0 000 0 0000 0 00000 0 0000 0 000 0 000 0
   1 0 11 0 111 0 1111 0 11111 0 1111 0 111 0 111 0
   0 1 11 1 111 1 1111 1 01111 1 0111 1 111 1 011 1
   0 0 00 0 001 0 0000 0 01000 0 0001 0 000 0 000 0
   1 0 01 0 110 0 1110 0 00001 0 0000 0 010 0 101 0
   0 0 11 0 111 0 1001 0 10111 0 1110 0 011 0 001 0
   0 0 01 0 110 0 0010 0 11001 0 0111 0 010 0 000 0
   1 0 01 0 010 0 0111 0 10110 0 1111 0 100 0 011 1

   4 2 66 2 667 2 6666 2 47666 2 4667 2 666 2 466 2
   9 0 4F 0 EF4 0 C9B5 0 7255E 0 5773 0 1E4 0 81D 1

   I   do   not   like   Green   Eggs   and   Ham !

  (I) (do) (not) (like) (Green) (Eggs) (and) (Ham)

 ['S', ['NP', 'i'],
       ['VP', 'do', ['ADV', 'not'], 'like'],
       ['NP', ['CONJ', 'and', ['NP', ['ADJ', 'green'], 'eggs'],
                              ['NP', 'ham']]]]

"""
