def get_starting_chunk ( filename , length = 1024 ) : # Ensure we open the file in binary mode with open ( filename , 'rb' ) as f : chunk = f . read ( length ) return chunk
reading a specified amount of bytes from a file python
: param filename : File to open and get the first little chunk of . : param length : Number of bytes to read default 1024 . : returns : Starting chunk of bytes .
def get_starting_chunk(filename, length=1024):
    """
    :param filename: File to open and get the first little chunk of.
    :param length: Number of bytes to read, default 1024.
    :returns: Starting chunk of bytes.
    """
    # Ensure we open the file in binary mode
    with open(filename, 'rb') as f:
        chunk = f.read(length)
        return chunk