Two Questions about Python on Windows
Ethan Furman
ethan at stoneleaf.us
Thu Apr 3 14:00:00 EDT 2014
On 04/03/2014 10:54 AM, Ian Kelly wrote:
> On Apr 3, 2014 11:12 AM, "Walter Hurry" wrote:
>>
>> 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.
Right. When specifying the file as a command-line argument to python, you have it include the extension, and that is
exactly the file that python executes. Also, using this method, a .pyc file is not created. Only imported files may
have a .py[co] file automatically created for corresponding .py file.
--
~Ethan~
More information about the Python-list
mailing list