[Python-ideas] os.path.isbinary

Ryan rymg19 at gmail.com
Wed Jul 31 21:03:43 CEST 2013


1.The link I provided wasn't how I wanted it to be. I was using it as an example to show it wasn't impossible.
2.You yourself stated it doesn't work on UTF-8 files. If you wanted one that worked on all text files, it wouldn't work right.
3.Did no one get the 'nothingness/is/eternal' joke?

So...although that is a nice piece of code, an os.path implementation would probably be more complete and foolproof.

Eli Bendersky <eliben at gmail.com> wrote:

>On Wed, Jul 31, 2013 at 8:40 AM, Ryan <rymg19 at 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

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130731/02837c22/attachment.html>


More information about the Python-ideas mailing list