A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-August/047331.html below:

[Python-Dev] Re: Recommended way to tell platform

[Python-Dev] Re: Recommended way to tell platform"Martin v. Löwis" martin at v.loewis.de
Sun Aug 8 09:02:21 CEST 2004
Guido van Rossum wrote:
> I still prefer hasattr(<module>, <attribute>) 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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4