Deprecation in String.joinfields()

Fredrik Lundh fredrik at
Mon Sep 25 16:26:48 CEST 2006

"Anoop" wrote:

> I am getting the following error while trying to use deprecation

deprecation ?

>>>> li = ["a", "b", "mpilgrim", "z", "example"]
>>>> newname = string.joinfields (li[:-1], ".")
>>>> newname
> 'a.b.mpilgrim.z'
>>>> newname = li[:-1].joinfields(".")
> Traceback (most recent call last):
>  File "<interactive input>", line 1, in ?
> AttributeError: 'list' object has no attribute 'joinfields'

you're trying to call the "joinfields" method on a list object.  lists don't have
such a method.  to join strings in a list using a separator, use


or in your case,

    newname = ".".join(li[:-1])

older code sometimes use the "join" function from the "string" module in-

    import string
    newname = string.join(li[:-1], separator)

string.joinfields is a really old spelling of string.join.  that's been deprecated
for a decade, or so.


More information about the Python-list mailing list