A port of Go's io.LimitReader to Python.
>>> from urllib.request import urlopen
>>> from limit_reader import LimitReader
>>> with urlopen('https://httpbin.org/bytes/1000') as resp:
... rdr = LimitReader(resp, 353)
... print(rdr.status) # proxies method
... data = rdr.read()
...
200
>>> print(len(data))
353
>>> with open('README.md') as fp:
... rdr = LimitReader(fp, 17)
... print(rdr.name) # proxied attribute
... data = rdr.read()
...
README.md
>>> print(len(data))
17