2

When to use os.name, sys.platform, or platform.system? suggests that os.name might be 'nt'. Reliably detect Windows in Python suggests that os.name is 'posix'.

Is it 'posix' or 'nt'?

Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670
  • So...is this a question? – Remi Guan Sep 16 '15 at 15:00
  • @KevinGuan The question is in the title. Though it's easy to find out if you have a windows box or a VM. – Colonel Thirty Two Sep 16 '15 at 15:04
  • @ColonelThirtyTwo Okay, I've seen the title but I thought that's too easy to know that...Sorry. – Remi Guan Sep 16 '15 at 15:12
  • 1
    It might depend on the specific Python build. – Harry Johnston Sep 16 '15 at 23:16
  • why the downvote? Do you think it is too easy? Are you sure? Can you *guarantee* that `os.name == 'posix'`? (have you a link to docs that promise that? Can you confirm it by running it on various combinations of Python/Windows/Cygwin versions?) – jfs Feb 09 '16 at 04:00
  • **Excellent question,** because I just needed to know this. It would appear that [this answer](http://stackoverflow.com/q/4553129/4279) was incorrect and [this answer](http://stackoverflow.com/q/1387222/4279) correct with respect to `os.name == 'posix'` on Cygwin. _May the upvotes shower you like rain._ – Cecil Curry Sep 01 '16 at 03:54

1 Answers1

6

On Cygwin64,

import os; print  os.name; 
import sys; print sys.platform;
import platform; print platform.system()

yields:

posix
cygwin
CYGWIN_NT-6.1
Kenney
  • 9,003
  • 15
  • 21