def getBytesFromFile(filename, offset, numBytes):
 if ((not isinstance(offset, int)) or (not isinstance(numBytes, int))):
  return ((-1), 'The offset and the number of bytes must be integers')
 if os.path.exists(filename):
  fileSize = os.path.getsize(filename)
  bytesFile = open(filename, 'rb')
  bytesFile.seek(offset)
  if ((offset + numBytes) > fileSize):
   bytes = bytesFile.read()
  else:
   bytes = bytesFile.read(numBytes)
  bytesFile.close()
  return (0, bytes)
 else:
  return ((-1), 'File does not exist')

def getBytesFromFile ( filename , offset , numBytes ) : if ( ( not isinstance ( offset , int ) ) or ( not isinstance ( numBytes , int ) ) ) : return ( ( - 1 ) , 'The offset and the number of bytes must be integers' ) if os . path . exists ( filename ) : fileSize = os . path . getsize ( filename ) bytesFile = open ( filename , 'rb' ) bytesFile . seek ( offset ) if ( ( offset + numBytes ) > fileSize ) : bytes = bytesFile . read ( ) else : bytes = bytesFile . read ( numBytes ) bytesFile . close ( ) return ( 0 , bytes ) else : return ( ( - 1 ) , 'File does not exist' )
returns the number of bytes specified from a file .