<div dir="ltr"><p dir="ltr"><br>
On Apr 3, 2014 11:12 AM, "Walter Hurry" <<a href="mailto:walterhurry@gmail.com" target="_blank">walterhurry@gmail.com</a>> wrote:<br>
><br>
> Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it runnable.<br>
><br>
> For my son's school assignment, I have to help him with Python for Windows.<br>
><br>
> As I understand it, on Windows a .py file is not executable, so I need to run 'python foo py', or use a .pyw file.<br>
><br>
> Question 1: Do I make a .pyw file simply by copying or renaming foo.py to foo.pyw?</p>
<p dir="ltr">Yes. The only distinction between .py and .pyw is that the Python installer associates the former with Python.exe and the latter with Pythonw.exe. Pythonw runs the script without creating a console window for stdin/stdout.</p>



<p dir="ltr">> Secondly, on *ix, if there's an up-to-date .pyc in the right place and I run foo.py, Python will automagically use foo.pyc.</p>
<p dir="ltr">I don't believe this is exactly correct. Python will only use a .pyc automatically for imported modules. For a file specified on the command line, Python won't try to second-guess the user as to which file they want.  The file could have a .php extension, and Python will happily run it if the contents are valid Python code.<br>

</p>

<p dir="ltr">> Question 2: Does it work the same way on Windows, and does this apply both to foo.py and foo.pyw?</p>
<p dir="ltr">Yes.<br>
</p>
</div>