Martin Panter <vadmium...@gmail.com> added the comment: If I remember the implementation of “peek” right, it may do what you want. But the documentation doesn’t guarantee much about its behaviour; see Issue 5811.
Anyway, I agree that a “getbuffn” method (or property) would be nice. (Perhaps with a better name!) But please don’t add it to the abstract APIs like BufferedIOBase. It could break compatibility with third-party implementations, or make the API complicated with little benefit. Just extend the concrete APIs like BufferedReader. Two other use cases where the “peek” implementation won’t help, but “getbuffn” would: 1. Issue 32561: Decide whether a non-blocking “read” call is possible, or if a background read (e.g. of a regular “disk” file) should be started instead. 2. Get the pending unread data before it is lost by calling ”BufferedReader.detach”. ---------- nosy: +martin.panter _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32475> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com