Re: python -m anomaly Was: quality of life improvements

-----Original Message----- From: Steven D'Aprano <steve@pearwood.info> Sent: 11 January 2020 04:39 To: python-ideas@python.org Subject: [Python-ideas] Re: python -m quality of life improvements On Fri, Jan 10, 2020 at 11:53:10PM -0300, Soni L. wrote:
Oh, a further thought comes to mind... if your modules aren't on the PYTHONPATH, just drop the -m and you can execute any legal Python file, even if the name isn't a legal identifier. [steve@ando tmp]$ cp ~/python/spam/eggs.py /tmp/"some name".foo [steve@ando tmp]$ python3.5 "some name.foo" some name.foo So as I understand it, the functionality you want already exists, both for running scripts on the path using -m and scripts with arbitrary file names without -m. Have I missed some subtlety in your proposal? [Steve Barnes] I did notice one anomaly in the behaviour of python -m: taking your code structure above and using :
py -mzipfile -c eggs.zip spam\__init__.py spam\__main__.py spam\eggs.py
to create eggs.zip I can run:
py eggs.zip
Renaming eggs.zip to eggs.py I can run:
But get problems when I try:
Gadget@GADGETLAPTOP E:\toolbuild
Is this expected behaviour or worth a ticket and some time investigating further? This was on Windows 10/64 with 3.8-64 but I get exactly the same with 3.7-64/32 & 2.7 and with python rather than py. Gadget/Steve

On Fri, Jan 10, 2020 at 10:24 PM Steve Barnes <GadgetSteve@live.co.uk> wrote:
It's expected behaviour. Passing a file path to the interpreter goes through some special logic to look for a zip file, while -m is basically fancy importing.

On Fri, Jan 10, 2020 at 10:24 PM Steve Barnes <GadgetSteve@live.co.uk> wrote:
It's expected behaviour. Passing a file path to the interpreter goes through some special logic to look for a zip file, while -m is basically fancy importing.
participants (2)
-
Brett Cannon
-
Steve Barnes