identifying 64-bit Windows from 2.3.5?

Trent Mick trentm at ActiveState.com
Thu Jun 9 11:33:33 EDT 2005


[Steven Knight wrote]
> If I have installed 2.3.5 from the python.org Windows installer, can
> any one point me to a run-time way to identify whether I'm running on
> a 32-bit vs. 64-bit version of Windows XP, given that Python itself was
> built on/for a 32-bit system?
> 
> I hoped sys.getwindowsversion() was the answer, but it returns the same
> platform value (2) on both 32-bit and 64-bit systems.  sys.platform
> ("win32") and sys.maxint are both set at compile time.  Things like
> os.uname() aren't on Windows.
> 
> Can some Windows-savvy Pythonista point me to some way to distinguish
> between these two?

To see if the Python you are running is 64-bit you can see how big a
pointer is:

    import struct
    struct.calcsize('P')

Mind you, you can run a 32-bit Python build on 64-bit-capable systems so
that may not be what you want.

Trent


-- 
Trent Mick
TrentM at ActiveState.com



More information about the Python-list mailing list