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

norseman norseman at hughes.net
Wed Jul 16 19:11:42 CEST 2008


 > > 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?
 > >
 > > Thanks, Ken

===========================================
 From what I'm reading I think the answer lies in being able to see 
Microsoft's OS 'About' statement.  One of the Python guru's should be 
able to supply the code.  On Linux you should be able to uname -m and 
get a pretty good idea. See man uname.

something like:
#contents of t.py
#-----------
import os
zstatflg= os.system("uname -m")
#-----------  EOF ---
then:
python t.py
i686

(I'm running a stock Python 2.5.2)

If the Python itself was compiled 32 bit and installed on a 64 bit 
machine that runs 32 bit code (like most all do during transition times) 
then all attempts with Python to check itself will return 32 bit 
responses. Using math and/or 'kibitz' (cheater text) will be useless.

Hope this helps;

Steve
norseman at hughes.net



More information about the Python-list mailing list