How to handle the pylint message: ID:W0612 Unused Variable

ぃ、小莉子 提交于 2019-12-03 22:19:36

I believe that a, dummy = func() does the trick. Pylint allows (if I recall correctly) unused variables names that start with _ or dummy, e.g. dummy_index.

You can configure this by passing --dummy-variables-rgx option to Pylint. This specifies the regex that catches dummy variable names.

Note: Using _ can indeed cause confusion (props: Sven Marnach). There's a convention to use single underscore as prefix for semi-private identifiers, the double underscore is of course the prefix for special Python methods and on top of that there's a convention to aliasgettext() function as _() in programs that need localization as in _("text to translate").

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!