import struct


def unpack_word(str, big_endian=False):
    """ Unpacks a 32-bit word from binary data.
    """
    endian = ">" if big_endian else "<"
    return struct.unpack("%sL" % endian, str)[0]