tags:

views:

70

answers:

1

Hi all.

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.

+6  A: 

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.

SilentGhost
Thanks. Perfect answer.
sukhbir