Skip to content

Dev: Cookbook

Gonzalo Peña-Castellanos edited this page Apr 20, 2015 · 14 revisions

A series of Python/Spyder common recipes to take into account when coding

Python

Make operations that depend on the Operating System (OS)

import os
import sys

# Operations for windows only
if os.name == 'nt':
    pass

# Operations for linux only
if sys.platform.startswith('linux'):
    pass

# Operations for Mac only
if sys.platform == 'darwin':
    pass

# Operations for unix (linux and mac)
if os.name != 'nt':
    pass

Clone this wiki locally