Pylint says 'string' module is deprecated.

2019-06-15 00:16发布

问题:

I was just pylinting some code and noticed a colleague had imported the old Python 'string' module, not to use any functions from it but simply to have access to the constant 'string.lowercase'.

I removed the deprecated import and substituted 'abcdef...' for string.lowercase, but I was wondering: is there a better way I should be doing this?

回答1:

string itself is not deprecated, just those methods like string.join that are better accessed through a string object. You can still import string, and get string.ascii_lowercase for what you want.

pylint's reporting this as an error is a known bug - see http://www.logilab.org/ticket/2481.



标签: python pylint