data = socket.read(dataToRead)
if TYPE_FOO == type:
    handleFoo(data)
elif TYPE_BAR == type:
    handleBar(data)
else:
    raise UnknownTypeException(type)
How to use Python and Google's Protocol Buffers to deserialize data sent over TCP