I need a way to tell what mode the shell is in from within the shell.
While I\'m primarily an OS X user, I\'d be interested in knowing about other platforms as well.<
platform.architecture() notes say:
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:
import sys
is_64bits = sys.maxsize > 2**32
struct.calcsize("P")
returns size of the bytes required to store a single pointer. On a 32-bit system, it would return 4 bytes. On a 64-bit system, it would return 8 bytes.
So the following would return 32
if you're running 32-bit python and 64
if you're running 64-bit python:
Python 2
import struct;print struct.calcsize("P") * 8
Python 3
import struct;print(struct.calcsize("P") * 8)
Basically a variant on Matthew Marshall's answer (with struct from the std.library):
import struct
print struct.calcsize("P") * 8
For a non-programmatic solution, look in the Activity Monitor. It lists the architecture of 64-bit processes as “Intel (64-bit)”.
Open python console:
import platform
platform.architecture()[0]
it should display the '64bit' or '32bit' according to your platform.
Alternatively( in case of OS X binaries ):
import sys
sys.maxsize > 2**32
# it should display True in case of 64bit and False in case of 32bit
Do a python -VV
in the command line. It should return the version.