On Wed, Jul 31, 2013 at 8:40 AM, Ryan <rymg19@gmail.com> wrote:
Here's something more interesting than my shlex idea.

os.path is, pretty much, the Python FS toolbox, along with shutil. But, there's one feature missing: check if a file is binary. It isn't hard, see http://code.activestate.com/recipes/173220/. But, writing 50 lines of code for a more common task isn't really Python-ish.

So...

What if os.path had a binary checker that works just like isfile:
os.path.isbinary('/nothingness/is/eternal') # Returns boolean


Some time ago I put on a gas mask and dove into the Perl source code to figure out how its "is binary" and "is text" operators work: http://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/

I would recommend against including such a simplistic heuristic in the Python stdlib.

Eli