Although it may work on some platforms, keep in mind that platform.architecture not always a reliable way to determine if python works in 32-bit or 64-bit. In particular, on some OS X multi-line architectures, the same executable file can work in any mode, as shown in the example below. The fastest secure multi-platform approach is to check sys.maxsize on Python 2.6, 2.7, Python 3.x.
$ arch -i386 /usr/local/bin/python2.7 Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import platform, sys >>> platform.architecture(), sys.maxsize (('64bit', ''), 2147483647) >>> ^D $ arch -x86_64 /usr/local/bin/python2.7 Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import platform, sys >>> platform.architecture(), sys.maxsize (('64bit', ''), 9223372036854775807) ), $ arch -i386 /usr/local/bin/python2.7 Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import platform, sys >>> platform.architecture(), sys.maxsize (('64bit', ''), 2147483647) >>> ^D $ arch -x86_64 /usr/local/bin/python2.7 Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import platform, sys >>> platform.architecture(), sys.maxsize (('64bit', ''), 9223372036854775807)
Ned Deily Dec 03 '09 at 20:30 2009-12-03 20:30
source share