<div dir="ltr">I would be okay if this change did not affect execution of a package with the python -m flag. I was only concerned because a __main__ in a package is common and wanted to make sure you had addressed it.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 9, 2015 at 6:48 PM, Cameron Simpson <span dir="ltr"><<a href="mailto:cs@zip.com.au" target="_blank">cs@zip.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 09Aug2015 20:34, Cameron Simpson <<a href="mailto:cs@zip.com.au" target="_blank">cs@zip.com.au</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 09Aug2015 03:05, Joseph Jevnik <<a href="mailto:joejev@gmail.com" target="_blank">joejev@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If I have a package that defines both a __main__ and a __init__, then your<br>
change would bind the __main__ to the name instead of the __init__. That<br>
seems incorrect.<br>
</blockquote>
<br>
Yes. Yes it does.<br>
</blockquote></span>
[...]<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
would it be enough to say that this change should only apply if the module is not a package?<br>
</blockquote>
<br></span>
I append the code for my testmod below, being an __init__.py and a __main__.py.  A run shows:<br>
<br>
 % python3.4 -m testmod<br>
 __init__.py: /Users/cameron/rc/python/testmod/__init__.py testmod testmod<br>
 __main__.py: /Users/cameron/rc/python/testmod/__main__.py __main__ testmod.__main__<br>
 __main__ <module 'testmod.__main__' from '/Users/cameron/rc/python/testmod/__main__.py'><br>
 testmod <module 'testmod' from '/Users/cameron/rc/python/testmod/__init__.py'><br>
<br>
(4 lines, should your mailer fold the output.)<br>
<br>
It seems to me that Python already does the "right thing" for packages, and it is only non-package modules which need the change proposed by the PEP.<br>
<br>
Comments please?<br>
<br>
Code below.<br>
<br>
Cheers,<br>
Cameron Simpson <<a href="mailto:cs@zip.com.au" target="_blank">cs@zip.com.au</a>><br>
<br>
testmod/__init__.py:<br>
   #!/usr/bin/python<br>
   print('__init__.py:', __file__, __name__, __spec__.name)<br>
<br>
testmod/__main__.py:<br>
   #!/usr/bin/python<br>
   import pprint<br>
   import sys<br>
   print('__main__.py:', __file__, __name__, __spec__.name)<br>
   for modname, mod in sorted(sys.modules.items()):<br>
     rmod = repr(mod)<br>
     if 'testmod' in modname or 'testmod' in rmod:<br>
       print(modname, rmod)<br>
</blockquote></div><br></div>