Ronald Oussoren <ronaldousso...@mac.com> added the comment:

Given a python script in a file named foo.py in the current directory:

* python -m foo  

  Should, and does, work.

* python -m foo.py

  Raises an error, because the command tries to run the submodule "py" of
  module "foo" as the __main__ module. For script files this will raise an
  error because module "foo" is not a package (hence the AttributeError about
  __path__).

  The error might get raised at the end of the script because the interpreter
  executes the module body on import before it looks for attributes and
  submodules.

* python foo

  Does not work because there is no file named "foo". This is expected 
  behaviour. 

* python foo.py

  Works because there is a file named foo.py. The interpreter executes the
  contents of the file.


"python NAME" and "python -m NAME" are not the same, which is why the two 
invocations behave differently. This is expected behaviour and not a bug.

See also "https://docs.python.org/3/using/cmdline.html#cmdoption-m";

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36514>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to