You can use the platform.architecture
function:
>>> import platform
>>> platform.architecture()
('64bit', '')
Pay attention to the note on the same page:
Note On Mac OS X (and perhaps other platforms), executable files may be universal files containing multiple architectures.
To get at the “64-bitness” of the current interpreter, it is more reliable to query the sys.maxsize attribute:
is_64bits = sys.maxsize > 2**32
Please keep in mind that this gives the word size with which the python interpreter was compiled. You could obtain a value of 32 on a 64bit host if python was compiled in 32bit mode.
If the file is produced by a different executable and you have access to this executable, you can use the first optional argument to the platform.architecture
function:
>>> p.architecture('/path/to/executable')
('32bit', '')
/sys
or/proc
on linux systems with sysfs/procfs exposes binary address values) – Graniela