On 14 October 2014 14:28, Angus Lees <g...@inodes.org> wrote:
> (Context: https://review.openstack.org/#/c/117418/)
>
> I'm looking for some rough consensus on what naming conventions we want for
> unused variables in Neutron, and across the larger OpenStack python codebase
> since there's no reason for Neutron to innovate here.
>
> As far as I can see, there are two cases:
>
>
> 1.  The "I just don't care" variable
>
> Eg:    _, _, filename = path.rpartition('/')
>
> In python this is very commonly '_', but this conflicts with the gettext
> builtin so we should avoid it in OpenStack.
>
> Possible candidates include:
>
> a.  'x'
> b. '__'  (double-underscore)
> c. No convention

b works for me, its aesthetically close to the _ for Python itself.

>
> 2.  "I know it is unused, but the name still serves as documentation"
>
> Note this turns up as two cases: as a local, and as a function parameter.
>
> Eg:   out, _err = execute('df', path)
>
> Eg:   def makefile(self, _mode, _other):
>             return self._buffer
>
> I deliberately chose that second example to highlight that the leading-
> underscore convention collides with its use for private properties.
>
> Possible candidates include:
>
> a. _foo   (leading-underscore, note collides with private properties)
> b. unused_foo   (suggested in the Google python styleguide)
> c. NOQA_foo   (as suggested in c/117418)
> d. No convention  (including not indicating that variables are known-unused)

I would say a) and don't signal function parameter use via the
parameter names: the only reason to have unused parameters is when we
are implementing a contract specified elsewhere, and in that case, the
parameter name from elsewhere should be used.

-Rob

-- 
Robert Collins <rbtcoll...@hp.com>
Distinguished Technologist
HP Converged Cloud

_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to