Adapting code to multiple platforms

Peter Hansen peter at engcorp.com
Mon Mar 14 04:08:14 CET 2005


Paul Watson wrote:
> "Peter Hansen" <peter at engcorp.com> wrote:
>>Simon John wrote:
>>>You could try import win32api and checking for an exception ;-)
>>
>>(Winky noted)  Just in case anyone thinks that last is a
>>useful idea, keep in mind that win32api is not installed
>>(with the standard distribution) but must be installed
>>with a separate download of the pywin32 package by Mark
>>Hammond.
> 
> How about try: import msvcrt 

Sure, that works, but it would make for pretty
inscrutable code if you were doing this just to
check whether you were on Windows, and not because
you really intended to use the msvcrt module.

sys.platform exists for a good reason.  Use it!



More information about the Python-list mailing list