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 ezio.melotti
Recipients docs@python, ethan.furman, ezio.melotti, nedbat, r.david.murray
Date 2015-07-15.15:22:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> The surprising thing is that __main__ works without there being an __init__.

That's also what surprised me, I always thought was supposed to be used within a package executed with "python -m pkg", but apparently "regular" dirs and zip files can have one too -- as long as they are executed as "python dir_or_zip".

This should have answered the question I posed in my first message: what is and what is its purpose?

As for the others:
Q: when should it be used?
A: whenever you want to make a package/dir/zip executable
Q: what should it contain?
A: usually an import + a function call that launches the app should be enough, but might contain more code if necessary
Q: is it ok to have other in the subpackages (e.g. test/ to run the tests with python -m package.test)?
A: this seems to work and should be OK
Q: how it interacts (which one is executed first?)
A: seems to be executed first.  I'm not aware of other interactions.

If these are indeed correct, a patch can be made (feel free to do it, since I don't when I'll have time to do it myself).
Date User Action Args
2015-07-15 15:22:04ezio.melottisetrecipients: + ezio.melotti, nedbat, r.david.murray, docs@python, ethan.furman
2015-07-15 15:22:04ezio.melottisetmessageid: <>
2015-07-15 15:22:04ezio.melottilinkissue24632 messages
2015-07-15 15:22:03ezio.melotticreate