Showing content from http://mail.python.org/pipermail/python-dev/attachments/20150320/408843e4/attachment.html below:
<div dir="ltr">FWIW, I would vote for the "__version__", "__author__", etc assignments being after the imports. Reason being cases where the "__version__" is not from VCS, but is calculated from pkg_resources:<div><br></div><div><span class="" style="color:rgb(167,29,93);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre">from</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre"> pkg_resources </span><span class="" style="color:rgb(167,29,93);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre">import</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre"> get_distribution</span><br></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre">__version__ </span><span class="" style="color:rgb(167,29,93);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre">=</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre"> get_distribution(</span><span class="" style="color:rgb(24,54,145);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre"><span class="">'</span>mypackage<span class="">'</span></span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre">).version</span><br></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre"><br></span></div><div>Also, then more useful things like "__all__" (which can very reasonably rely on imports), can be together with "__version__" and "__author__" assignments.</div><div><br></div><div>I would vote:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>shebang</div><div>docstring</div><div>imports</div><div>dunder assignments</div><div>other code...</div></blockquote><br><div></2 cents></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><br>~ Ian Lee<br></div></div>
<br><div class="gmail_quote">On Fri, Mar 20, 2015 at 9:24 PM, Ian Lee <span dir="ltr"><<a href="mailto:ianlee1521@gmail.com" target="_blank">ianlee1521@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Guido,</p>
<p dir="ltr">In that case would you be open to a patch to update the PEP accordingly?</p>
<p dir="ltr">Additionally, does that official statement cover other dunder assignments (e.g. "__author__"?). If so I'll update the PEP8 tool accordingly.</p>
<p dir="ltr">Thanks,</p>
<p dir="ltr">~ Ian Lee</p>
<div class="gmail_quote"><div><div class="h5">On Mar 20, 2015 8:55 PM, "Guido van Rossum" <<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>FWIW, I think __version__, __author__ etc. were bad ideas. Almost nobody manages these correctly. Note that the PEP 8 section starts with less than an endorsement: "If you <b>have</b> to have Subversion, CVS, or RCS crud in your source file,
do it as follows."<br><br></div>That said, if an official answer is required, common sense would suggest that __version__ should go before the imports. (I would put it before the docstring too, except then the docstring wouldn't be a docstring any more. Go figure.)<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 20, 2015 at 6:38 PM, Ben Finney <span dir="ltr"><<a href="mailto:ben+python@benfinney.id.au" target="_blank">ben+python@benfinney.id.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>Lewis Coates <<a href="mailto:lewisc@pdx.edu" target="_blank">lewisc@pdx.edu</a>> writes:<br>
<br>
> In pep8 there are two conflicting statements, both<br>
><br>
> <a href="https://www.python.org/dev/peps/pep-0008/#version-bookkeeping" target="_blank">https://www.python.org/dev/peps/pep-0008/#version-bookkeeping</a><br>
> <a href="https://www.python.org/dev/peps/pep-0008/#imports" target="_blank">https://www.python.org/dev/peps/pep-0008/#imports</a><br>
><br>
> Stipulate that they should be "at the top of the file after any module<br>
> comments and docstrings." Which of these takes precedence?<br>
<br>
</span>I don't know an official answer. The convention I've observed is<br>
overwhelmingly in one direction: import statements come before any<br>
assignment statements.<br>
<span><br>
> Secondly, we also have an "__author__", and "__project__" variables, I<br>
> assume these would be put with the version information as well?<br>
<br>
</span>Yes.<br>
<span><font color="#888888"><br>
--<br>
 \   âWelchen Teil von âGestaltâ verstehen Sie nicht? [What part of |<br>
 `\        âgestaltâ don't you understand?]â âKarsten M. Self |<br>
_o__)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |<br>
Ben Finney<br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" target="_blank">https://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div>--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>
<br>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br></div></div>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/ianlee1521%40gmail.com" target="_blank">https://mail.python.org/mailman/options/python-dev/ianlee1521%40gmail.com</a><br>
<br></blockquote></div>
</blockquote></div><br></div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4