Lists into Strings..?
Jay Parlar
jparlar at home.com
Wed Aug 29 16:20:11 EDT 2001
If I understand you correctly, then it's a simple matter of using the 'join()' function, part of the 'string' library.
import string
lExistingList = ['spam','Spam','SPAM','bacon','Bacon']
sNewString = string.join(lExistingList)
Unless I've misunderstood you, that should do it.
> Hiya!
>
> I am wondering of the best* way to make string equal to an entire list of
> strings.
>
> >>> lExistingList = ['spam','Spam','SPAM','bacon','Bacon']
> >>> sNewString = lExistingList
>
> just doesn't seem to do it.
>
> I know that I can write the list out to a file, and then read the whole
> file in, but that seems like so much overkill to me.
>
> Thanks heaps!
>
> tefol
>
> *I let you define best anyway you like. That seems to be the Python way.
> :-)
>
> Cha!
More information about the Python-list
mailing list