[Python-ideas] PEP for executing a module in a package containingrelative imports (original) (raw)

Terry Reedy tjreedy at udel.edu
Fri Apr 20 20:13:44 CEST 2007


"Brett Cannon" <brett at python.org> wrote in message news:bbaeab100704192038v110b053eqfdcf49f613302f8 at mail.gmail.com... | Let me know what you think. I especially want to hear which proposal | people prefer; the one in the PEP or the one in the Open Issues section.

This PEP has two proposals, which I think should be better separated.

  1. Leave name alone (without the 'main' hack) so that relative imports work when executing scripts within packages. My comment here is that I am fuzzy on the difference between name and file and why we would then need both.

  2. Fix the 'main' self-knowledge problem introduced by fix 1. The 'counter-proposal' is only an alternative to this second proposal, as it agree with the first. I had the same idea as Christian as a third alternative, but as a user would prefer the simplest invocation possible. I agree with Jim that multiple alternatives should be listed.

I think the 'main' hack was both elegant and a wart, and agree that we should seriously consider a pair of coupled fixes.

| Plus I wouldn't mind suggestions on a title for this PEP.| =)

Package scripts, relative imports, and main identification.

Terry Jan Reedy



More information about the Python-ideas mailing list