[Python-Dev] Recommended way to tell platform (original) (raw)
Guido van Rossum guido at python.org
Sat Aug 7 18:37:00 CEST 2004
- Previous message: [Python-Dev] Asyncore .set_reuse_addr() on Windows
- Next message: [Python-Dev] Recommended way to tell platform
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
A.M. Kuchling wrote: > Question: should the condition be sys.platform.startswith('win') for > the sake of win64, or other Windows variants? (I don't know which > values sys.platform can have on Windows.)
Win64 also uses "win32" as sys.platform. If you really want to find out this is not x86, you need to look at the compiler ID in sys.version. Regards, Martin
This does bring up an interesting question: what's the recommended way to distinguish a certain platform? There's os.name, sys.platform, the platform module, and I've also seen code testing for os.sep=='/'.
I still prefer hasattr(, ) whenever applicable, e.g. preferring hasattr(os, 'fork') over os.name=='posix' (or os.name!='nt' :-), but sometimes that's not possible.
What should be the preferred way? (It may be impossible to say because there are different use cases, but probably one of the most important cases is simply distinguishing Windows from the rest -- how should that be done?)
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Asyncore .set_reuse_addr() on Windows
- Next message: [Python-Dev] Recommended way to tell platform
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]