Finding the bitness of an arbitrary executable with Python

Irmen de Jong irmen.NOSPAM at xs4all.nl
Mon May 9 17:10:25 EDT 2011


On 9-5-2011 22:52, 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). 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).

A few options are mentioned here:

http://stackoverflow.com/questions/1345632/determine-if-an-executable-or-library-is-32-or-64-bits-on-windows

-irmen




More information about the Python-list mailing list