Unix file(1) command identifing .pyc
drt
drt-usenet at un.bewaff.net
Tue May 28 17:38:59 EDT 2002
The Unix file command identifies the type of a file using,
among other tests, a test for whether the file begins with a certain
magic number. The actual version (3.38) can't identify compiled
python code. I have added the macic numbers for python and
successfully tested on 2.2.1 and 2.1.3 on i386 and PowerPC machines.
Perhaps somebody has acient Python versions or unusual machines to
further test this.
The magic file can be found at
http://c0re.jp/c0de/misc/file-3.38-magic-python
Usage example:
$ curl -O http://c0re.jp/c0de/misc/file-3.38-magic-python
$ file -m file-3.38-magic-python /usr/local/lib/python*/cgi.pyc
file: Using regular magic file `file-3.38-magic-python'
/usr/local/lib/python2.1/cgi.pyc: python 2.1.x compiled bytecode
/usr/local/lib/python2.2/cgi.pyc: python 2.2.x compiled bytecode
$
drt
More information about the Python-list
mailing list