Join strings - very simple Q.

John Machin sjmachin at lexicon.net
Fri Mar 23 16:15:29 EDT 2007


On Mar 24, 5:37 am, Paulo da Silva <psdasil... at esotericaX.ptX> wrote:
> Hi!
>
> I was told in this NG that string is obsolet. I should use
> str methods.
>
> So, how do I join a list of strings delimited by a given
> char, let's say ','?
>
> Old way:
>
> l=['a','b','c']
> jl=string.join(l,',')
>
> New way?
>

Self-help #1: reading the documentation: http://www.python.org/doc/2.0/lib/string-methods.html
?
Change "0" to "5" to get the latest released version -- which hasn't
changed the description of the join method AFAICT.

Self-help #2: help() at the interactive prompt:

Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
| >>> help("".join)
Help on built-in function join:

join(...)
    S.join(sequence) -> string

    Return a string which is the concatenation of the strings in the
    sequence.  The separator between elements is S.

| >>>

OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
released. Where have you been in the last ~6.5 years?

HTH,
John




More information about the Python-list mailing list