<div dir="ltr">+1 for readable, well-documented code </bikeshed></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 13, 2014 at 8:28 PM, Angus Lees <span dir="ltr"><<a href="mailto:gus@inodes.org" target="_blank">gus@inodes.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(Context: <a href="https://review.openstack.org/#/c/117418/" target="_blank">https://review.openstack.org/#/c/117418/</a>)<br>
<br>
I'm looking for some rough consensus on what naming conventions we want for<br>
unused variables in Neutron, and across the larger OpenStack python codebase<br>
since there's no reason for Neutron to innovate here.<br>
<br>
As far as I can see, there are two cases:<br>
<br>
<br>
1. The "I just don't care" variable<br>
<br>
Eg: _, _, filename = path.rpartition('/')<br>
<br>
In python this is very commonly '_', but this conflicts with the gettext<br>
builtin so we should avoid it in OpenStack.<br>
<br>
Possible candidates include:<br>
<br>
a. 'x'<br>
b. '__' (double-underscore)<br>
c. No convention<br>
<br>
<br>
2. "I know it is unused, but the name still serves as documentation"<br>
<br>
Note this turns up as two cases: as a local, and as a function parameter.<br>
<br>
Eg: out, _err = execute('df', path)<br>
<br>
Eg: def makefile(self, _mode, _other):<br>
return self._buffer<br>
<br>
I deliberately chose that second example to highlight that the leading-<br>
underscore convention collides with its use for private properties.<br>
<br>
Possible candidates include:<br>
<br>
a. _foo (leading-underscore, note collides with private properties)<br>
b. unused_foo (suggested in the Google python styleguide)<br>
c. NOQA_foo (as suggested in c/117418)<br>
d. No convention (including not indicating that variables are known-unused)<br>
<br>
<br>
As with all style discussions, everyone feels irrationally attached to their<br>
favourite, but the important bit is to be consistent to aid readability (and<br>
in this case, also to help the mechanical code checkers).<br>
<br>
Vote / Discuss / Suggest additional alternatives.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
- Gus<br>
<br>
_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</font></span></blockquote></div><br></div>