I just ran pylint
on my code and it shows up this message:
Uses of a deprecated module 'string'
I am using the module string
for join / split mainly.
>>> names = ['Pulp', 'Fiction']
>>> import string
>>> fullname = string.join(names)
>>> print fullname
Pulp Fiction
Above is an example. In my code I have to make use of split
and join
a lot and for that I was using the string
module.
Has this been deprecated? If yes, what is the way to handle split/ join in Python 2.6? I have tried searching but I could not find myself being clear so I asked here.
Equivalent to your code would be:
' '.join(names)
string
is not deprecated, deprecated are certain functions that were duplicates of str
methods. For split
you could also use:
>>> 'Pulp Fiction'.split()
['Pulp', 'Fiction']
In docs there is a full list of deprecated functions with suggested replacements.
not all functions from "strings" are deprecated. if you want to use a function from strings which is not deprecated, then remove a string from deprecated-modules configuration in pylint config.
[IMPORTS]
deprecated-modules=string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With