On Wed, Jul 31, 2013 at 5:42 PM, Chris Angelico <rosuav@gmail.com> wrote:This sounds more like a job for a file-like object, maybe a subclassof file that reads (and buffers) the first 512 bytes, guesses whether
it's text or binary, and then watches everything that goes through
after that and revises its guess later on.Something like:if fh.read(512).isprintable():do_the_ascii_stuff(fh)else:do_the_bin_stuff(fh)--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas