[Python-Dev] Re: Recommended way to tell platform (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Sun Aug 8 09:02:21 CEST 2004
- Previous message: [Python-Dev] Recommended way to tell platform
- Next message: [Python-Dev] Re: Recommended way to tell platform
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
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?)
Precisely that: impossible to say. In most cases, you should not test for the platform, but just use the platform functionality, and fall back to something else if it isn't present.
However, to reliably distinguish Windows from the rest, check whether os.platform is "win32".
Regards, Martin
- Previous message: [Python-Dev] Recommended way to tell platform
- Next message: [Python-Dev] Re: Recommended way to tell platform
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]