Finding the bitness of an arbitrary executable with Python
Robert Kern
robert.kern at gmail.com
Mon May 9 17:22:47 EDT 2011
On 5/9/11 3:52 PM, Andrew Berg wrote:
> I need to find whether a given file is 32-bit or 64-bit (and raise an
> exception if the file doesn't exist or isn't an executable file). I
> thought platform.architecture() would do this, but it returns ('64bit',
> '') no matter what value I assign to the executable parameter (looks
> like it uses the given executable to find info on the underlying system
> rather than info on the specific file, reverting to sys.executable if
> there are any errors).
Actually, that information is built into the Python interpreter when it gets
built. It is not actually examining the file referenced by sys.executable.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list