title: Why is .pyc file created sometimes in same directory and sometimes in __pycache__ subdirectory?
body: <p>I am using Windows 7 and have both Python 2.7.5 and 3.3.2 installed. My <code>path</code> environment variable is set as </p>
  
  <pre><code>C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\python27;C:\Python33\Scripts
  </code></pre>
  
  <p>When I import any Python module into another module a <code>.pyc</code> file is created. The place where it is created depends on whether Python2 is invoked or Python3 to run it. </p>
  
  <ul>
  <li>when I double-click the module the <code>.pyc</code> file is created in the same directory </li>
  <li>when I am editing via IDLE and then run it then the file is created in the subdirectory. </li>
  <li>If I add <code>#! Python3</code> at the top then double-clicking makes the <code>.pyc</code> file in the sub-directory.</li>
  </ul>
  
  <p>I understand that the reason for this is because of difference in how Python2 and Python3 have decided to manage the byte-compiled codes.</p>
  
  <p><strong>I am currently focusing on Python3 and want the files to be created in subdirectory only.</strong></p>
  
  <p>I tried editing the <code>path</code> variable to place Python3 before Python 2 so that Python3 should be invoked instead of Python2. Even after changing it when I double-click the Python script that didn't happen and the byte-compiled code was created in the same directory. </p>
  
  <p>So Python2 was used to run the Python script on double-clicking. What is causing this behaviour and how can I make sure that Python3 is invoked instead of Python2 without uninstalling Python2?</p>