How to figure out if the platform is 32bit or 64bit?

Trent Mick trentm at activestate.com
Fri Jul 25 15:50:10 EDT 2008


norseman wrote:
> 
>  > > I need to know if I'm running on 32bit or 64bit ... so far I haven't
>  > > come up with how to get this info via python. sys.platform returns
>  > > what python was built on ... but not what the current system is.
>  > >
>  > > I thought platform.uname() or just platform.processor() would have
>  > > done it, but python returns an empty string on windows. Any ideas?

If just for Windows I believe you can use the "PROCESSOR_ARCHITECTURE" 
environment variable -- at least on NT-based Windows versions.

Values are x86 (32-bit), IA64 (64-bit) and AMD64 (64-bit).

Here is a "platinfo.py" module that might help if you need to do this 
for other platforms:

http://svn.openkomodo.com/openkomodo/view/openkomodo/trunk/util/platinfo.py


Cheers,
Trent

-- 
Trent Mick
trentm at activestate.com



More information about the Python-list mailing list