This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davide.rizzo
Recipients davide.rizzo, docs@python, ethan.furman, ezio.melotti, nedbat, r.david.murray
Date 2015-07-16.08:42:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
As far as I understand, assuming dir/ contains a file

$ python dir

is equivalent to

$ python dir/

in that it's behaviourally nothing more than executing a script in that dir and setting sys.path accordingly. This is the same in Python 2 and Python 3.

This, together with the notion that zip files and directories are treated in the same way, allows running


since we have no option for executing a file *within* the zip file.

Altogether, this is a significantly different behaviour than the one for "python -m pkg". That would be closer to:

>>> import pkg.__main__

This also explains why the package __init__ is executed first (you import the package first, then the module). A significant difference is that it's not a real import (just as pkg.__init__ is not imported) and sys.modules is not affected.
Date User Action Args
2015-07-16 08:42:39davide.rizzosetrecipients: + davide.rizzo, nedbat, ezio.melotti, r.david.murray, docs@python, ethan.furman
2015-07-16 08:42:39davide.rizzosetmessageid: <>
2015-07-16 08:42:39davide.rizzolinkissue24632 messages
2015-07-16 08:42:38davide.rizzocreate