Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Windows': 0.02; 'subject:Python': 0.06; 'correct.': 0.07; 'subject:Questions': 0.07; "'python": 0.09; 'executable': 0.09; 'imported': 0.09; 'latter': 0.09; 'present,': 0.09; 'windows,': 0.09; 'runs': 0.10; 'python': 0.11; 'up-to-date': 0.14; 'windows': 0.15; '.py': 0.16; 'extension,': 0.16; 'happily': 0.16; 'modules.': 0.16; 'renaming': 0.16; 'second-guess': 0.16; 'subject:Two': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'normally': 0.19; '(the': 0.22; 'command': 0.22; 'email addr:gmail.com>': 0.22; 'creating': 0.23; 'file.': 0.24; 'question': 0.24; 'script': 0.25; '>': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'specified': 0.30; 'message- id:@mail.gmail.com': 0.30; 'linux.': 0.31; 'yes.': 0.31; 'file': 0.32; 'run': 0.32; 'copying': 0.34; 'could': 0.34; 'received:google.com': 0.35; 'done': 0.36; 'window': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'associates': 0.60; 'simply': 0.61; 'school': 0.64; 'between': 0.67; 'believe': 0.68; 'line,': 0.68; 'freebsd': 0.84; 'installer': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=/miawKPvxxSbEuRwTLyVreMDDhRWXurRGku3GC3RxgM=; b=NS8fQsN585+7wGy1wH2Ox32uyKxeTNyhlayJ5Ur2qdpRROqjan82HEYnupVUZ5Vkw1 ywqFQwseAEfeS72ica8gT5xBMZxxrbNfzy5C6G/DLtu8PkoftrXkksaCnRS3sRBwh95N clIE5hvuq5GcSEgj9eapu2jaPYtMYuPYU8Ok8F9mdQaoSJwdHKZ0+9WY3YfxaIu3PpF5 uqjq6aiZH09omk/VpSKKFkT9eFI+Q1f6G9iaLLSiwSKjWlQ41SDitvE6nsIkVl/8Em5N rJWSlfvVu/4yO5+NNOgRS2eypOmzbgEuFXeDp12yoVRTMa/DbkPsPwULmKDlnGQl4PXn YwkQ== X-Received: by 10.66.141.144 with SMTP id ro16mr8926454pab.131.1396547684875; Thu, 03 Apr 2014 10:54:44 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Thu, 3 Apr 2014 11:54:04 -0600 Subject: Re: Two Questions about Python on Windows To: Python Content-Type: multipart/alternative; boundary=001a1133316cab44e004f6271880 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 82 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396547693 news.xs4all.nl 2872 [2001:888:2000:d::a6]:34557 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69597 --001a1133316cab44e004f6271880 Content-Type: text/plain; charset=ISO-8859-1 On Apr 3, 2014 11:12 AM, "Walter Hurry" wrote: > > 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. > > For my son's school assignment, I have to help him with Python for Windows. > > 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. > > Question 1: Do I make a .pyw file simply by copying or renaming foo.py to foo.pyw? 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. > 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. 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. > Question 2: Does it work the same way on Windows, and does this apply both to foo.py and foo.pyw? Yes. --001a1133316cab44e004f6271880 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Apr 3, 2014 11:12 AM, "Walter Hurry" <walterhurry@gmail.com> wrote:<= br> >
> Normally my Python development is done on FreeBSD and Linux. I know th= at on *ix I simply have to make foo.py executable (the shebang line is pres= ent, of course) to make it runnable.
>
> For my son's school assignment, I have to help him with Python for= Windows.
>
> 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.
>
> Question 1: Do I make a .pyw file simply by copying or renaming foo.py= to foo.pyw?

Yes. The only distinction between .py and .pyw is that the P= ython installer associates the former with Python.exe and the latter with P= ythonw.exe. Pythonw runs the script without creating a console window for s= tdin/stdout.

> 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.

I don't believe this is exactly correct. Python will onl= y use a .pyc automatically for imported modules. For a file specified on th= e command line, Python won't try to second-guess the user as to which f= ile they want.=A0 The file could have a .php extension, and Python will hap= pily run it if the contents are valid Python code.

> Question 2: Does it work the same way on Windows, and d= oes this apply both to foo.py and foo.pyw?

Yes.

--001a1133316cab44e004f6271880--