Python version of perl's "if (-T ..)" and "if (-B ...)"?
Aahz
aahz at pythoncraft.com
Fri Feb 12 09:26:51 EST 2010
In article <mailman.2434.1265983307.28905.python-list at python.org>,
Lloyd Zusman <ljz at asfast.com> wrote:
>
>Perl has the following constructs to check whether a file is considered
>to contain "text" or "binary" data:
>
>if (-T $filename) { print "file contains 'text' characters\n"; }
>if (-B $filename) { print "file contains 'binary' characters\n"; }
Assuming you're on a Unix-like system or can install Cygwin, the
standard response is to use the "file" command. It's *much* more
sophisticated.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
More information about the Python-list
mailing list