examples/files/read_binary.py
#!/usr/bin/env python

file = 'README'

try:
    fh = open(file, 'rb')
    while True:
        str = fh.read(5000)
        print(len(str))
        if len(str) == 0:
            break
        # do something with the content of the str

    fh.close()
except Exception:
    pass

# 5000
# 5000
# 5000
# 1599
# 0