I came across this interesting question my friend asked me. He told that he found a way to know which os we are on without importing the os module. Can any of you help me with the same?
            Asked
            
        
        
            Active
            
        
            Viewed 68 times
        
    -3
            
            
         
    
    
        ForceBru
        
- 43,482
- 10
- 63
- 98
 
    
    
        Sukesh Raghav
        
- 11
- 1
- 
                    For example: `import platform; platform.uname()` – ForceBru Mar 13 '21 at 11:21
- 
                    1Does this answer your question? [Python: What OS am I running on?](https://stackoverflow.com/questions/1854/python-what-os-am-i-running-on) – Gino Mempin Mar 13 '21 at 11:27
2 Answers
1
            
            
        import platform
print(platform.system())
print(platform.release())
print(platform.version())
 
    
    
        liagason
        
- 93
- 2
- 10
- 
                    `platform` imports `os`, so maybe this is not what the OP wanted. – Christian K. Mar 13 '21 at 11:29
1
            perhaps this could work:
if r"\" in __file__: print("Windows") 
else: print("Unix variant")
 
    
    
        Alain T.
        
- 40,517
- 4
- 31
- 51