I need a way to tell what mode the shell is in from within the shell.
I've tried looking at the platform module but it seems only to tell you about "about the bit architecture and the linkage format used for the executable": the binary is compiled as 64bit though (I'm running on OS X 10.6) so it seems to always report 64bit even though I'm using the methods described here to force 32bit mode).
3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)]
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 and64
if you're running 64-bit python:Python 2
Python 3
On my Centos Linux system I did the following:
1) Started the Python interpreter (I'm using 2.6.6)
2) Ran the following code:
and it gave me
Basically a variant on Matthew Marshall's answer (with struct from the std.library):
For a non-programmatic solution, look in the Activity Monitor. It lists the architecture of 64-bit processes as “Intel (64-bit)”.
When starting the Python interpreter in the terminal/command line you may also see a line like:
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Where
[MSC v.1500 64 bit (AMD64)]
means 64-bit Python. Works for my particular setup.