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

Ken Hartling kjhishere at gmail.com
Wed Jul 16 09:16:33 EDT 2008


Thanks .. but I want to find out if the system is "running on 64bit" even
when the interpreter is a
32-bit build executable ("what python was built on").
platform.architecture() and platform() in general seems to only be looking
at the build executable and what it was built for on windows (sorry, I don't
have a unix box available at the moment).  platform.architecture() returns
32bit when on a windows 64bit box.

Another recommendation was:
import sys
hex(sys.maxint)
x = sys.maxint
n = 1
while x:
    n += 1
    x >>= 1

print n

Unfortunately this too appears to be looking at the build executable ... on
Windows 64 it returns '32'.

Thanks for the suggestions, hopefully we'll come up with a winner.

Ken


On Tue, Jul 15, 2008 at 1:39 PM, Benjamin Kaplan <benjamin.kaplan at case.edu>
wrote:

>
>
> On Tue, Jul 15, 2008 at 4:10 PM, <kjhishere at gmail.com> 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?
>>
>> Thanks, Ken
>> --
>
>
> platform.architecture() should have it.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080716/083b21a8/attachment-0001.html>


More information about the Python-list mailing list