Finding the bitness of an arbitrary executable with Python

Andrew Berg bahamutzero8825 at gmail.com
Mon May 9 16:52:52 EDT 2011


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). A quick look on Google doesn't give me anything
useful. Something cross-platform would be nice, but it really only needs
to work on Windows (on win32 binaries).



More information about the Python-list mailing list