os.name under Win32

Igor Kravtchenko igor at mekensleep.com
Fri Sep 1 11:27:10 EDT 2006


Hi!

We have an application using Python that is intended to work both under 
Win32 and Linux.
Since some parts of the code need to be different depending whether we 
are under Win32
or Linux, we use the traditional:

if os.name == "posix":
  some Linux code
else:
  some Win32 code

However, we have noticed that under some circumstances, in some cases, 
in some
computers under Windows XP Family that the "posix" code was executed causing
of course a crash.

My question is whether that is supposed to be totally impossible.
Under Win32, we are indeed supposed to have os.name = "nt".  Is that value
hardcoded in Win32 binaries distribution themself?  Can it potentially 
change?

The purpose of this thread would be to have confirmed that under Win32,
os.name cannot never, ever be equal to "posix", whatever happens and so,
that we must have done some other mistakes elsewhere.

Thanks for any enlighting,

Igor.




More information about the Python-list mailing list