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
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