Hello, Anoop wrote:
> I am getting the following error while trying to use deprecation > > Please help > >>>> 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' > >>>> newname1 = string.join (li[:-1], ".") >>>> newname1 > '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 'join' > > Thank you for your help joinfields is just an alias for join and only the latter is a method of the string class (which should be used instead of the deprecated string.join function), which means that the string "." has a method join which takes the list as an argument. So what you want should be written as: newname = ".".join(li[:-1]) HTH -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://pink.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list