Cross platform code in python
<p>How can I write in python some windows code to execute only when I am running the script in widnows, if I should run it in linux, that part of the windows code should be ignored, something simillar to this, in C++:  </p>

<pre><code>#ifdef windows
  //code
#endif

#ifdef linux
//code
#endif
</code></pre>

<p>I tried something like this in python:</p>

<pre><code>if os.name = 'nt':
   #code
</code></pre>

<p>But in linux it gives me an error(I am using STARTF_USESHOWWINDOW, witch gives error).</p>

<pre><code>startupinfo = None
if sys.platform == 'win32':
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW #error here
    startupinfo.wShowWindow = _subprocess.SW_HIDE # error here

Traceback (most recent call last):
  File "/home/astanciu/workspace/test/src/main.py", line 10, in &lt;module&gt;
    import _subprocess
ImportError: No module named _subprocess
</code></pre>
